Simulating gcm notification from console

In this post I will show only example of using gcm notification broadcasting from console. I assume You have working gcm methods in your project.
You must change also in manifest two things.
1. In gcm receiver You must remove SEND
2. In permission list paste permission to send gcms.

android:permission=""//<--REMOVE, COPY TO CLIPBOARD
<action android:name="" />
<category android:name="${applicationId}" />
<action android:name="" />
<category android:name="${applicationId}" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="" />//<--PASTE PERMISSION HERE

Below pattern “how-to” and example.

//adb shell am broadcast -a <Intent-Name> -n <Package>/<Receiver-Name-with-leading-dot> <Extras>

My app needs some params (–es is kind of argument [key-value]).

adb shell am broadcast -a -c -n --es "key1" "abc" --es "key2" "def"

Notepad++ with regex, re-using match variables

Here is an simple example how to use regex in notepad++ with reusing selected match variables.

For example we have special code for simulating gcm notifications. We would like to see it in pretty style.
To achieve this we must to move all elements with minus to the new lines. How to do it? Here is the solution.

We have this string:
adb shell am broadcast -a -c -n --es "aaa" "123" --es "mmm" "bla bla bla" --es "sss" "321" --es "from" "111" --es "type" "yesterday" --es "collapse_key" "do_not_collapse"

By using bellow command in notepad++:

Searching text:


Replace with:


We get the quite pretty result:

adb shell am broadcast
--es "aaa" "123"
--es "mmm" "bla bla bla"
--es "sss" "321"
--es "from" "111"
--es "type" "yesterday"
--es "collapse_key" "do_not_collapse"

GCM notification with custom sound – shorter version (part)

Here is a short example how to create notification with default stuff but different sound:

NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setStyle(new NotificationCompat.BigTextStyle()
.setDefaults(NotificationCompat.DEFAULT_ALL ^ NotificationCompat.DEFAULT_SOUND);

The most important part is here:

.setDefaults(NotificationCompat.DEFAULT_ALL ^ NotificationCompat.DEFAULT_SOUND)



says “except”, so the last part would say “give me default notification except sound setting”