私はアンドロイドが初めてです。私のアプリケーションの 1 つで、GCM サービスを使用しています。一部のデバイスでは問題なく動作しています。ただし、通知を受信すると、一部のデバイスでアプリケーションがクラッシュします。
以下は私のコードです..
private static void generateNotification(Context context, String message) {
long when = System.currentTimeMillis();
NotificationManager notificationManager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.ic_launcher, message, when);
String title = "Application";
Intent notificationIntent = new Intent(context, MainActivity.class);
notificationIntent.putExtra("message", message);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent =
PendingIntent.getActivity(context, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, title, message, intent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.defaults|= Notification.DEFAULT_LIGHTS;
notification.defaults|= Notification.DEFAULT_VIBRATE;
notification.flags |= Notification.FLAG_SHOW_LIGHTS;
notificationManager.notify(0, notification);
}
のように、このコードで一部の行を取り消し線として表示しますnew Notification
。
誰でも問題を教えてもらえますか?
グーグルで調べたところ、これらの機能は新しいバージョンでは減価償却されていることがわかりました。では、新しいバージョンのコードを使用できますか?
次に、新しい API 用にコーディングした場合、このアプリケーションは古いバージョンと互換性がありますか? 現在の私のminSdkVersion=8 and targetSdkVersion=16
よろしくお願いします 助けてください