Notification service not working after clicking notification message in status bar
Date : March 29 2020, 07:55 AM
help you fix your problem I referred following links to study the demo example on Notification service in Android : Sai Geetha Blog and Vogella Tutorial. , check this out public static NotificationManager nm;
public static final int UNIQUE_ID = 123458;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.newone);
createNotification();
}
public void createNotification() {
NotificationManager nm= (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
final int UNIQUE_ID = 123458;
Intent navigationIntent = new Intent();
navigationIntent.setClass(NEWAct.this,
TestActivity.class);
navigationIntent.putExtra("selected_tab", "more");
PendingIntent pi = PendingIntent.getActivity(this, 0, navigationIntent,
0);
String body = "New Notification added!!!";
String title = "Title";
Notification n = new Notification(R.drawable.ic_launcher, body,
System.currentTimeMillis());
n.number = 2;
n.setLatestEventInfo(this, title, body, pi);
n.defaults = Notification.DEFAULT_ALL;
nm.notify(UNIQUE_ID, n);
}
try {
nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
nm.cancel(UNIQUE_ID);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
|
NoClassDefFoundError with GoogleCloudMessaging
Date : March 29 2020, 07:55 AM
around this issue I've solved using those steps: Sync with Gradle Rebuild Project Generate APK and Run again.
|
gcm GoogleCloudMessaging new implementation
Date : March 29 2020, 07:55 AM
may help you . I tried to update from the gcm.jar to get the GCM from the google-play-services.jar. I'm using the same code as shown here. , You forgot to change the package name in the permissions. <permission android:name="com.example.gcm.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.gcm.permission.C2D_MESSAGE" />
<permission android:name="com.mintmark.TestGcm.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.mintmark.TestGcm.permission.C2D_MESSAGE" />
|
GoogleCloudMessaging example
Date : March 29 2020, 07:55 AM
I wish this helpful for you Ya you are right but there is also one directory named gcm client
|
Robolectric and GoogleCloudMessaging
Date : March 29 2020, 07:55 AM
seems to work fine Small mistake ... the line builder.addInstrumentedClass( .. ); specify a class which could be shadowed. Instead of the ShadowGCM use the GoogleCloudMessaging at this point. The part manifest = "src/main/AndroidManifest.xml" may give you trouble later. Instead you should take the manifest from build directory which is already done by RobolectricGradleTestRunner. If you have issues in AndroidStudio then read "Note for Linux and Mac Users" at http://robolectric.org/getting-started/
|