1

私は自分のAndroidアプリのプッシュ通知を統合しました、私はすべてのAndroidモバイル/タブのプッシュ通知をオン/オフにしたいです、誰かが私を助けてくれますか...

protected void onPostExecute(BlogInfo result){
            if(result.IsNew && result.Blog != null){
                NotificationManager manager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
                Notification notification = new Notification(R.drawable.logo, "THE BUTCHER BARKS", System.currentTimeMillis());
                notification.flags |= Notification.FLAG_AUTO_CANCEL;
                notification.defaults |= Notification.DEFAULT_ALL;

                Intent intent = new Intent(Service.this, Bark.class);
                PendingIntent pendingIntent = PendingIntent.getActivity(GuruService.this, 0, intent, 0);
                notification.setLatestEventInfo(getApplicationContext(), "BARKS", result.Blog.Title, pendingIntent);
                manager.notify(1, notification);
            }
        }
4

1 に答える 1

2

プッシュ メッセージがオンかオフかにかかわらず、共有設定に 1 つの値を保存します。

その後、プッシュ メッセージがアプリに到着するたびに、GCMIntentService の onMessage メソッドが呼び出されます。次に、onMessage 内に条件を記述します。

protected void onMessage(Context arg0, Intent arg1) {
        // TODO Auto-generated method stub
            if(preference.getPushStatus().equals("ON"))
        Log.d("onMessage",arg1.getExtras().getString("message"));   

}
于 2012-10-10T06:15:27.133 に答える