Android - ayuda con notificaciones

 
Vista:

ayuda con notificaciones

Publicado por Luis Rodriguez (8 intervenciones) el 07/12/2017 18:51:13
Cuando llega las notificaciones y la aplicación esta en primer plano va directo a la activity especificada, el problema es cuando la aplicación esta en segundo plano y llega una notificación va es a la activity principal no a la especificada, que puedo hacer para solventarlo.

clase para realizar lo ante expuesto

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
public class NotificationService extends FirebaseMessagingService {
 
    public static final String TAG = "FIREBASE";
    private int ONGOING_NOTIFICATION_ID;
 
 
    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        //super.onMessageReceived(remoteMessge);
        Log.d(TAG, "From: " + remoteMessage.getFrom());
        Log.d(TAG, "Notification Message Body: " + remoteMessage.getNotification().getBody());
 
        Intent i = new Intent(this, Activity_Tres.class);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_ONE_SHOT);
 
        Uri sonido = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
 
        NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                .setSmallIcon(R.drawable.logo_in)
                .setContentTitle("Notification")
                .setContentText(remoteMessage.getNotification().getBody())
                .setAutoCancel(true)
                .setSound(sonido)
                .setContentIntent(pendingIntent);
 
 
        NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
       notificationManager.notify(0, builder.build());
 
    }
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
manifest
 
    <uses-permission android:name="android.permission.INTERNET" />
 
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
 
        <activity android:name=".Activity_Uno">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
 
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".Activity_Dos"
            android:label="@string/title_a"
            android:parentActivityName=".Activity_Uno"
            android:theme="@style/AppTheme.NoActionBar">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:theme="@style/AppTheme.NoActionBar"
                android:value=".Activity_Uno" />
        </activity>
        <activity
            android:name=".Activity_Tres"
            android:label="@string/title_b"
            android:parentActivityName=".Activity_Uno"
            android:theme="@style/AppTheme.NoActionBar">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:theme="@style/AppTheme.NoActionBar"
                android:value=".Activity_Uno" />
        </activity>
 
        <service
            android:name=".NotificationService">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT"/>
            </intent-filter>
        </service>
 
    </application>
 
</manifest>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder