Я использую GCM. Я хочу остановить GcmListenerService, чтобы я мог остановить приложение от получения нежелательного уведомления.Стоп GcmListenerService progmatically
Я попытался ниже, чтобы закрыть сервис, но это не кажется тренировки
Intent intent = new Intent(this, MyGcmListenerService.class);
stopService(intent);
Вот мой класс обслуживания
public class MyGcmListenerService extends GcmListenerService
{
private static final String TAG = "MyGcmListenerService";
// [START receive_message]
@Override
public void onMessageReceived(String from, Bundle data) {
String message = data.getString("message");
String duration = data.getString("duration");
Log.d(TAG, "From: " + from);
Log.d(TAG, "Message: " + message);
sendNotification(message,duration);
}
// [END receive_message]
private void sendNotification(String message, String duration) {
new DisplayNotification(this).makeGCMNotification("Event Name", "Event Start Time", 1);
}
}
и в очевидном
<service
android:name=".Utilities.GCM.MyGcmListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
</intent-filter>
</service>
Я просто не хочу получать уведомления в какой-то момент в приложении. Пожалуйста, помогите – Ajeet