0

들어오는 모든 푸시 알림을 클릭 할 때마다 앱을 특정 활동 페이지로 리디렉션하기 위해 고심하고 있습니다. 나는 안드로이드 개발에 처음이고 프로그래밍에 대해 미안하다.푸시 알림을 클릭하면 특정 활동으로 리디렉션됩니다. android studio

다음은 푸시 알림 부분에 대한 android manifest.xml입니다.

<!-- GCM requires a Google account. --> 
<uses-permission android:name="android.permission.GET_ACCOUNTS" /> 

<permission 
    android:name="com.younginnovators.sjk.permission.C2D_MESSAGE" 
    android:protectionLevel="signature" /> 
<!-- VERY IMPORTANT! Don't forget this permission, or in-app billing won't work. --> 

<uses-permission android:name="com.younginnovators.sjk.permission.C2D_MESSAGE" /> 
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> 

<application 
    android:allowBackup="true" 
    android:icon="@mipmap/icon" 
    android:label="@string/app_name" 
    android:largeHeap="true" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme"> 
    <activity android:name=".MainActivity"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
    <!-- Push Notifications Receiver --> 
    <receiver 
     android:name=".backgroundservices.PushNotificationBroadcastReceiver" 
     android:permission="com.google.android.c2dm.permission.SEND"> 
     <intent-filter> 
      <action android:name="com.google.android.c2dm.intent.RECEIVE" /> 
      <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> 

      <category android:name="com.younginnovators.sjk" /> 
     </intent-filter> 
    </receiver> 
    <!-- /Push Notifications Receiver --> 


    <!-- Push Notifications Service --> 
    <service android:name=".backgroundservices.PushnotificationService" /> 
    <!-- /Push Notifications Service --> 
+0

"GCM은"사용되지 않습니다 뭔가를 시도 할 수 있습니다 -이 :이 주제에 의견이있는 경우 감사합니다. Firebase로 업그레이드하십시오. 문서는 이해하기가 더 간단합니다 ... 그런데 실제 문제가 무엇인지 말하지 않았습니다. – muratgu

+0

안녕하세요 muratgu, 내 문제는 내 앱이 현재 푸시 알림을 클릭 한 후 홈페이지로 이동합니다. 푸시 알림을 클릭 할 때마다 특정 페이지로 리디렉션 할 수 있는지 궁금합니다. – aznelite89

+0

조언을 주셔서 감사합니다. 파이어베이스를 한번도 사용해 본적이 없습니다. – aznelite89

답변

0

당신은이

NotificationManager notificationManager = (NotificationManager) context 
     .getSystemService(Context.NOTIFICATION_SERVICE); 
Notification notification = new Notification(icon, message, when); 

Intent notificationIntent = new Intent(context, HomeActivity.class); 

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; 
notificationManager.notify(0, notification); 
+0

매니페스트 또는 다른 활동 클래스의 코드? – aznelite89

+0

기본 활동 클래스에서 해당 코드를 사용해보십시오. 알림에 대한 자세한 내용은 https://developer.android.com/guide/topics/ui/notifiers/notifications.html – user3678528

관련 문제