Help us understand the problem. What is going on with this article?

Push通知からアプリを開く

More than 5 years have passed since last update.
GCMIntentService.java
    @Override
    protected void onMessage(Context context, Intent intent) {
        String ticker = intent.getStringExtra("ticker");
        String title = intent.getStringExtra("title");
        String message = intent.getStringExtra("message");

        // プロセスがあればそのまま復帰、なければ起動画面から開始する
        Intent ni = new Intent(Intent.ACTION_MAIN);
        ni.addCategory(Intent.CATEGORY_LAUNCHER);
        ni.setClassName(getApplicationContext().getPackageName(), SplashActivity.class.getName());
        ni.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_NEW_TASK);
        PendingIntent pi = PendingIntent.getActivity(context, 0, ni, PendingIntent.FLAG_CANCEL_CURRENT);

        // 通知を開いたときに表示されるアイコン
        NotificationCompat.Builder builder = new Builder(context);
        builder.setTicker(ticker); // ステータスバーに表示されるテキスト
        builder.setContentTitle(title); // 通知を開いたときに表示されるタイトル
        builder.setContentText(message);// 通知を開いたときに表示されるメッセージ
        builder.setSmallIcon(R.drawable.ic_launcher); // ステータスバーに表示されるアイコン設定
        builder.setAutoCancel(true); // 通知をクリックした時に自動的に通知を消すように設定
        builder.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE | Notification.DEFAULT_LIGHTS);
        builder.setContentIntent(pi); // 通知が選択された時に起動するIntentを設定
        Notification notification = builder.build();
        NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        manager.notify(0, notification);
    }
imp954sti
フリーランスエンジニア 主にソーシャルゲームのクライアント開発のメインプログラマをやっています たまにサーバもみます。 Unity/Cocos2d-x/iOS/Android/ActionScript3
https://tri-blitz.com
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした