D
D
Denis Kotlyarov2015-08-09 22:16:50
Java
Denis Kotlyarov, 2015-08-09 22:16:50

The code with NotificationCompat doesn't work on android 2.3.7, what's the problem?

The code works on android 4.2.2 but doesn't work on 2.3.7 Here is the code:
` public static void StatusBarCompat(Context context, int index ,int img, String name, String subname, String perexod, Boolean nast){ Intent notificationIntent; notificationIntent= new Intent(context, UChat.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent contentIntent =
PendingIntent.getActivity(context, index, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
.setSmallIcon(img)
.setContentTitle(name)
.setContentIntent(contentIntent);
if(!perexod.equals(""))builder.setTicker(perexod);
if(!podname.equals(""))builder.setContentText(subname);
Notification notification = builder.build();
if(nast)notification.flags = notification.flags | Notification.FLAG_ONGOING_EVENT;
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
notificationManager.notify(index, notification);
}`
And here is the error log:
08-09 17:31:46.460 1988-1988/ux.uchat E/AndroidRuntime﹕ FATAL EXCEPTION: main java.lang.NoClassDefFoundError: ux.uchat.UChat at ux.uchat.StatusBar.StatusBarCompat(StatusBar.java:17) at ux.uchat.Post.Post(Post.java:34) at ux.uchat.Servers.getServerUpdate(Servers.java:97) at ux.uchat.Servers$1StartAct.onPostExecute(Servers.java:41) at ux.uchat .Servers$1StartAct.onPostExecute(Servers.java:23) at android.os.AsyncTask.finish(AsyncTask.java:417) at android.os.AsyncTask.access$300(AsyncTask.java:127) at android.os.AsyncTask $InternalHandler.handleMessage(AsyncTask.java:429) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main( ActivityThread.java:3683) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) at dalvik.system.NativeStart.main(Native Method)
Stops at:
at ux.uchat.StatusBar.StatusBarCompat(StatusBar.java:17)
notificationIntent= new Intent(context, UChat.class);

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question