アプリケーションが通知を送信しています。ユーザーが通知を確認して通知をクリックしたときに実装したいアプリケーションのメイン画面でポップアップを開きたいメイン画面がそのままの状態のままであるようなものです。その前にアップが開きます。前もって感謝します
2880 次
4 に答える
2
とが必要にBroadcast a intent
なりますIntent Receiver
以下は私のcreate Notification
コードです。ユーザーが通知アイコンをクリックしたときに、インテントをブロードキャストする必要があります。
// create NotificationManager..
NotificationManager mNotificationManager = (NotificationManager) this
.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.icon, null,
System.currentTimeMillis());
// create intent that will be broadcast.
Intent i = new Intent();
i.setClassName(this, BReceiver.class.getName());
i.setAction("Test");
PendingIntent contentIntent = PendingIntent.getBroadcast(this, 0,
i, 0);
notification.setLatestEventInfo(this, null, null, contentIntent);
mNotificationManager.notify(0, notification);
以下は私のBroadCast Receiver
public class BReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent)
{
Log.d("Test", "########## intent action "+ intent.getAction());
Toast.makeText(context, "Hi", Toast.LENGTH_LONG).show();
}
}
通知アイコンをクリックするとトーストが表示されます。どの画面を表示していても、ユーザーが通知アイコンをクリックするたびにトーストが表示されます。
于 2012-11-05T08:16:50.233 に答える
1
これを入れて
android:theme="@android:style/Theme.Dialog"
あなたのターゲット活動のために意味で
于 2012-11-05T06:41:41.290 に答える
0
Alert Builderを使用してみてください。これは、コードのスニペットです。
new AlertDialog.Builder(this).
setCancelable(false).
setTitle("Title for popup").
setMessage("Show Message here").
setNeutralButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
System.exit(0);
}
}).create().show();
于 2012-11-05T06:31:33.157 に答える
0
基本的に、通知をクリックしたときにダイアログ(アクティビティとして作成したと想定しています)を開く方法について質問している場合は、Notification.BuilderクラスのaddActionメソッドに関する通知ドキュメントを確認してください。通知をクリックすると、指定したインテントを起動できます。
于 2012-11-05T06:52:56.600 に答える