1

タブビュー(小さな画面の約1/3を要した)から、通知メッセージを介して選択可能なフルスクリーンに切り替えようとしていました。

これまでのところ、多くのハウツーの指示に従ってすべてがうまく機能しています。(それはsdkエミュレータにあります)

今、私はアプリを実際の Android 電話に転送しましたが、通知を介して画面を切り替えることはもうありません。常に MainActivity を開きます。

private void DroiDCNotification(int NotificationID, CharSequence tickerText, CharSequence contentTitle, CharSequence contentText) {
    //throw new UnsupportedOperationException("Not yet implemented");
    String ns = Context.NOTIFICATION_SERVICE;
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
    int icon = R.drawable.droidc_icon;        // icon from resources
    long when = System.currentTimeMillis();         // notification time
    Context context = getApplicationContext();      // application Context
    Intent notificationIntent = new Intent(this, MainActivity.class);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
    // the next two lines initialize the Notification, using the configurations above
    Notification notification = new Notification(icon, tickerText, when);
    notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
    mNotificationManager.notify(NotificationID, notification);
}

では、特定のアクティビティによって呼び出された通知を、指定したアクティビティを開くにはどうすればよいですか?

4

2 に答える 2

1

タブビュー(小さな画面の約1/3を要した)から、通知メッセージを介して選択可能なフルスクリーンに切り替えようとしていました。

なぜこれがいい考えだと思うのか、私にはわかりません。通知は、このロール用に設計されていません。オプションメニューをご利用ください。

では、特定のアクティビティによって呼び出された通知を、指定したアクティビティを開くにはどうすればよいですか?

を実行する予定PendingIntentです。あなたは識別をPendingIntentラップします。を使用したい場合は、希望するクラスに変更してください。IntentMainActivity.classMainActivity.classMyActivity.class

于 2010-12-23T18:34:15.440 に答える
0

こんにちは、今年の活動でこの 2 行を使用してください

Intent notificationIntent = new Intent(context, SamplePushActivity.class);
    PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
于 2012-08-16T09:37:28.950 に答える