Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think it helps you:</p> <pre><code>public String Sender_id = "your_google_api_sender_id"; try { GCMRegistrar.checkDevice(this); GCMRegistrar.checkManifest(this); String regId = GCMRegistrar.getRegistrationId(this); if (regId.equals("")) { GCMRegistrar.register(this, Sender_id); } else { } } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } </code></pre> <p>And in GCm Srevice we have to write like this:</p> <pre><code>public class GCMIntentService extends GCMBaseIntentService { @Override protected void onError(Context context, String error) { // TODO Auto-generated method stub if (error != null) { // optionally retry using exponential back-off // (see Advanced Topics) Toast.makeText(getBaseContext(), "" + error, Toast.LENGTH_SHORT) .show(); } } public GCMIntentService() { super("your_snde_id"); // SENDER_ID is my project id into google account url // TODO Auto-generated constructor stub } public GCMIntentService(String senderId) { super(senderId); // TODO Auto-generated constructor stub } @Override protected void onMessage(Context context, Intent intent) { String message = intent.getStringExtra("message"); // TODO Auto-generated method stub //createNotification(context, message); } @Override protected void onRegistered(Context context, String regId) { // TODO Auto-generated method stub // you need to handle what you have to do after registration } @Override protected void onUnregistered(Context context, String error) { // TODO Auto-generated method stub } } </code></pre> <p>and In Manifest file like this:</p> <pre><code> &lt;permission android:name="your.package.permission.C2D_MESSAGE" android:protectionLevel="signature" /&gt; &lt;uses-permission android:name="your.package.permission.C2D_MESSAGE" /&gt; &lt;!-- App receives GCM messages. --&gt; &lt;uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /&gt; &lt;receiver android:name="com.google.android.gcm.GCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" &gt; &lt;intent-filter&gt; &lt;action android:name="com.google.android.c2dm.intent.RECEIVE" /&gt; &lt;action android:name="com.google.android.c2dm.intent.REGISTRATION" /&gt; &lt;action android:name="com.google.android.c2dm.intent.UNREGISTER" /&gt; &lt;category android:name="com.activelifeapps.android.alAlleghany" /&gt; &lt;/intent-filter&gt; &lt;/receiver&gt; &lt;service android:name="your.package.GCMIntentService" /&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload