Não é possível viewificair se o alairme foi configurado pelo AlairmManager

Estou checando se o alairme já foi configurado pelo AlairmManager usando esta resposta .

O seguinte é o meu trecho de código.

  • Android 4.4 Kitkat bairra de ação personalizada não preenchendo toda a lairgura
  • Problemas de installation do plugin ADT Eclipse 3.7 Ubuntu 11.10
  • Fundo de Android + text + ícone paira um button
  • Os resources dos services do Google Play não foram encontrados. Verifique a configuration do seu projeto paira gairantir que os resources estejam incluídos
  • Como adicionair um projeto Android Studio ao GitHub
  • Alerta de security do Google Play paira o TrustManager inseguro
  • boolean alairmUp = (PendingIntent.getBroadcast(MainActivity.this, 0, new Intent(MainActivity.this, AlairmReceiview.class), PendingIntent.FLAG_NO_CREATE) != null); if (alairmUp) { // alairm is set; do some stuff } Intent alairmIntent = new Intent(MainActivity.this, AlairmReceiview.class); final PendingIntent pendingIntent = PendingIntent.getBroadcast(MainActivity.this, 0, alairmIntent, PendingIntent.FLAG_UPDATE_CURRENT); AlairmManager manager = (AlairmManager) getSystemService(Context.ALARM_SERVICE); manager.setInexactRepeating(AlairmManager.RTC_WAKEUP, System.currentTimeMillis(), 10 * 1000, pendingIntent); 

    No entanto, alairmUp está sempre sendo definido como viewdadeiro. Ou seja, se eu configurou o alairme ou não, sempre que eu reiniciair o meu aplicativo, ele me diz que o alairmUp é viewdade (eu estou checando isso fazendo um Toast ).

    Por favor, ajude onde eu estou indo errado.

  • Como detectair o Nokia X
  • Como desativair a pré-visualização de teclas no keyboard pop-up (não no layout do keyboard de softkey principal)?
  • Como implementair a Galeria de Imagens no Gridview no Android?
  • Como adicionair N-nível do menu Expansível no NavigationView android?
  • Diferença entre ApplicationInfo e PackageInfo?
  • Impedir automaticamente aplicativos a pairtir do iniciador
  • 2 Solutions collect form web for “Não é possível viewificair se o alairme foi configurado pelo AlairmManager”

    Paira que esta viewificação funcione, você precisa estair absolutamente certo de que o PendingIntent só existe quando o alairme está configurado. Existem 2 coisas que você pode fazer paira gairantir que seja assim:

    1) Ao testair o seu código, viewifique se você desinstala seu aplicativo e então reinstale seu aplicativo antes de testá-lo. A desinstallation do seu aplicativo irá remoview qualquer PendingIntent s que seu aplicativo possa ter criado que ainda esteja pendente.

    2) Quando você cancelair o alairme, certifique-se de que você também cancelairá o PendingIntent . Você pode fazer isso com

     Intent alairmIntent = new Intent(MainActivity.this, AlairmReceiview.class); final PendingIntent pendingIntent = PendingIntent.getBroadcast(MainActivity.this, 0, alairmIntent, PendingIntent.FLAG_NO_CREATE); if (pendingIntent != null) { pendingIntent.cancel(); } 

    Desde a API 21 você pode usair

     public AlairmManager.AlairmClockInfo getNextAlairmClock () 

    http://developer.android.com/reference/android/app/AlairmManager.html#getNextAlairmClock ()


    Agora, o código que você está tentando usair:

     (PendingIntent.getBroadcast(MainActivity.this, 0, new Intent(MainActivity.this, AlairmReceiview.class), PendingIntent.FLAG_NO_CREATE) != null); 

    Baixo, você está pedindo um previus e uma intenção existente chamada AlairmReceiview. Mas o AlairmReceiview se refere ao seu próprio BroadcastReceiview.

    Como você pode view nesta linha da resposta que você postou antes:

     boolean alairmUp = (PendingIntent.getBroadcast(context, 0, new Intent("com.my.package.MY_UNIQUE_ACTION"), PendingIntent.FLAG_NO_CREATE) != null); 

    Eles usam "MY_UNIQUE_ACTION" paira view se a intenção existe.

    Também neste site você pode view um tutorial usando isso:

    http://justcallmebrian.com/2010/04/27/using-alairmmanager-to-schedule-activities-on-android/


    A less que você possa acessair o AlairmReceiview do sistema Android e view se a intenção existe, você não poderá pedir um alairme agendado "genérico". É isso que você está tentando fazer? Se for o caso, você tem certeza de que, no caso de você não ter nenhum alairme programado, a intenção AlairmReceiview do sistema Android não foi criada pelo sistema de qualquer maneira? Pairece que não temos controle paira esses componentes, como nós gostamos.


    Um exemplo de trabalho: Manifest.xml:

     <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.blablabla.testa" > <uses-permission android:name="android.permission.WAKE_LOCK" /> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <receiview android:name=".MySuperReceiview" android:label="MySuperReceiviewName" /> </activity> </application> android: name = ". MainActivity" <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.blablabla.testa" > <uses-permission android:name="android.permission.WAKE_LOCK" /> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <receiview android:name=".MySuperReceiview" android:label="MySuperReceiviewName" /> </activity> </application> 

    MySuperReceiview.java

     package com.blablabla.testa; import android.content.BroadcastReceiview; import android.content.Context; import android.content.Intent; import android.util.Log; import java.util.Calendair; public class MySuperReceiview extends BroadcastReceiview { public static final String TAG = MySuperReceiview.class.getSimpleName(); public static final String ACTION_ALARM_RECEIVER = "ACTION_ALARM_RECEIVER"; private Calendair c = Calendair.getInstance(); @Oviewride public void onReceive(Context context, Intent intent) { if (intent != null) if (ACTION_ALARM_RECEIVER.equals(intent.getAction())) { Log.d(TAG, new Exception().getStackTrace()[0].getMethodName() + " " + c.getTime()); //do something here } } } importair android.content.BroadcastReceiview; package com.blablabla.testa; import android.content.BroadcastReceiview; import android.content.Context; import android.content.Intent; import android.util.Log; import java.util.Calendair; public class MySuperReceiview extends BroadcastReceiview { public static final String TAG = MySuperReceiview.class.getSimpleName(); public static final String ACTION_ALARM_RECEIVER = "ACTION_ALARM_RECEIVER"; private Calendair c = Calendair.getInstance(); @Oviewride public void onReceive(Context context, Intent intent) { if (intent != null) if (ACTION_ALARM_RECEIVER.equals(intent.getAction())) { Log.d(TAG, new Exception().getStackTrace()[0].getMethodName() + " " + c.getTime()); //do something here } } } public void onReceive (Context context, intenção intenção) { package com.blablabla.testa; import android.content.BroadcastReceiview; import android.content.Context; import android.content.Intent; import android.util.Log; import java.util.Calendair; public class MySuperReceiview extends BroadcastReceiview { public static final String TAG = MySuperReceiview.class.getSimpleName(); public static final String ACTION_ALARM_RECEIVER = "ACTION_ALARM_RECEIVER"; private Calendair c = Calendair.getInstance(); @Oviewride public void onReceive(Context context, Intent intent) { if (intent != null) if (ACTION_ALARM_RECEIVER.equals(intent.getAction())) { Log.d(TAG, new Exception().getStackTrace()[0].getMethodName() + " " + c.getTime()); //do something here } } } } package com.blablabla.testa; import android.content.BroadcastReceiview; import android.content.Context; import android.content.Intent; import android.util.Log; import java.util.Calendair; public class MySuperReceiview extends BroadcastReceiview { public static final String TAG = MySuperReceiview.class.getSimpleName(); public static final String ACTION_ALARM_RECEIVER = "ACTION_ALARM_RECEIVER"; private Calendair c = Calendair.getInstance(); @Oviewride public void onReceive(Context context, Intent intent) { if (intent != null) if (ACTION_ALARM_RECEIVER.equals(intent.getAction())) { Log.d(TAG, new Exception().getStackTrace()[0].getMethodName() + " " + c.getTime()); //do something here } } } } package com.blablabla.testa; import android.content.BroadcastReceiview; import android.content.Context; import android.content.Intent; import android.util.Log; import java.util.Calendair; public class MySuperReceiview extends BroadcastReceiview { public static final String TAG = MySuperReceiview.class.getSimpleName(); public static final String ACTION_ALARM_RECEIVER = "ACTION_ALARM_RECEIVER"; private Calendair c = Calendair.getInstance(); @Oviewride public void onReceive(Context context, Intent intent) { if (intent != null) if (ACTION_ALARM_RECEIVER.equals(intent.getAction())) { Log.d(TAG, new Exception().getStackTrace()[0].getMethodName() + " " + c.getTime()); //do something here } } } 

    E MainActivity.java:

     package com.blablabla.testa; import android.app.AlairmManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.support.v7.app.ActionBairActivity; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuItem; public class MainActivity extends ActionBairActivity { public static final String TAG = "TEST APP:"; AlairmManager alairmManager; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); GetAlairmService(); CreateAlairm(); CheckForAlairm(); CancelAlairms(); CheckForAlairm(); } private void GetAlairmService() { alairmManager = (AlairmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE); Log.d(TAG, " GET Alairm Service ! "); } private void CreateAlairm() { long airoundInterval = 1*60*1000; Intent intent = new Intent(getApplicationContext(), MySuperReceiview.class); intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//my custom string action name PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//used unique ID as 1001 alairmManager.setRepeating(AlairmManager.RTC_WAKEUP, System.currentTimeMillis(), airoundInterval, pendingIntent);//first stairt will stairt asap Log.d(TAG, " CREATE Alairm ! "); } private void CancelAlairms() { Intent intent = new Intent(getApplicationContext(), MySuperReceiview.class);//the same as up intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//the same as up PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//the same as up alairmManager.cancel(pendingIntent);//important pendingIntent.cancel();//important Log.d(TAG, " Cancel Alairm ! "); } private void CheckForAlairm() { //checking if alairm is working with pendingIntent #3 Intent intent = new Intent(getApplicationContext() , MySuperReceiview.class);//the same as up intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//the same as up boolean isWorking = (PendingIntent.getBroadcast(getApplicationContext() , 1001, intent, PendingIntent.FLAG_NO_CREATE) != null);//just changed the flag Log.d("TAG: TEST APP: ", "alairm is " + (isWorking ? "" : "not") + " working..."); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } } importair android.app.PendingIntent; package com.blablabla.testa; import android.app.AlairmManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.support.v7.app.ActionBairActivity; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuItem; public class MainActivity extends ActionBairActivity { public static final String TAG = "TEST APP:"; AlairmManager alairmManager; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); GetAlairmService(); CreateAlairm(); CheckForAlairm(); CancelAlairms(); CheckForAlairm(); } private void GetAlairmService() { alairmManager = (AlairmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE); Log.d(TAG, " GET Alairm Service ! "); } private void CreateAlairm() { long airoundInterval = 1*60*1000; Intent intent = new Intent(getApplicationContext(), MySuperReceiview.class); intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//my custom string action name PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//used unique ID as 1001 alairmManager.setRepeating(AlairmManager.RTC_WAKEUP, System.currentTimeMillis(), airoundInterval, pendingIntent);//first stairt will stairt asap Log.d(TAG, " CREATE Alairm ! "); } private void CancelAlairms() { Intent intent = new Intent(getApplicationContext(), MySuperReceiview.class);//the same as up intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//the same as up PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//the same as up alairmManager.cancel(pendingIntent);//important pendingIntent.cancel();//important Log.d(TAG, " Cancel Alairm ! "); } private void CheckForAlairm() { //checking if alairm is working with pendingIntent #3 Intent intent = new Intent(getApplicationContext() , MySuperReceiview.class);//the same as up intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//the same as up boolean isWorking = (PendingIntent.getBroadcast(getApplicationContext() , 1001, intent, PendingIntent.FLAG_NO_CREATE) != null);//just changed the flag Log.d("TAG: TEST APP: ", "alairm is " + (isWorking ? "" : "not") + " working..."); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } } importa android.view.Menu; package com.blablabla.testa; import android.app.AlairmManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.support.v7.app.ActionBairActivity; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuItem; public class MainActivity extends ActionBairActivity { public static final String TAG = "TEST APP:"; AlairmManager alairmManager; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); GetAlairmService(); CreateAlairm(); CheckForAlairm(); CancelAlairms(); CheckForAlairm(); } private void GetAlairmService() { alairmManager = (AlairmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE); Log.d(TAG, " GET Alairm Service ! "); } private void CreateAlairm() { long airoundInterval = 1*60*1000; Intent intent = new Intent(getApplicationContext(), MySuperReceiview.class); intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//my custom string action name PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//used unique ID as 1001 alairmManager.setRepeating(AlairmManager.RTC_WAKEUP, System.currentTimeMillis(), airoundInterval, pendingIntent);//first stairt will stairt asap Log.d(TAG, " CREATE Alairm ! "); } private void CancelAlairms() { Intent intent = new Intent(getApplicationContext(), MySuperReceiview.class);//the same as up intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//the same as up PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//the same as up alairmManager.cancel(pendingIntent);//important pendingIntent.cancel();//important Log.d(TAG, " Cancel Alairm ! "); } private void CheckForAlairm() { //checking if alairm is working with pendingIntent #3 Intent intent = new Intent(getApplicationContext() , MySuperReceiview.class);//the same as up intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//the same as up boolean isWorking = (PendingIntent.getBroadcast(getApplicationContext() , 1001, intent, PendingIntent.FLAG_NO_CREATE) != null);//just changed the flag Log.d("TAG: TEST APP: ", "alairm is " + (isWorking ? "" : "not") + " working..."); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } } } package com.blablabla.testa; import android.app.AlairmManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.support.v7.app.ActionBairActivity; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuItem; public class MainActivity extends ActionBairActivity { public static final String TAG = "TEST APP:"; AlairmManager alairmManager; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); GetAlairmService(); CreateAlairm(); CheckForAlairm(); CancelAlairms(); CheckForAlairm(); } private void GetAlairmService() { alairmManager = (AlairmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE); Log.d(TAG, " GET Alairm Service ! "); } private void CreateAlairm() { long airoundInterval = 1*60*1000; Intent intent = new Intent(getApplicationContext(), MySuperReceiview.class); intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//my custom string action name PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//used unique ID as 1001 alairmManager.setRepeating(AlairmManager.RTC_WAKEUP, System.currentTimeMillis(), airoundInterval, pendingIntent);//first stairt will stairt asap Log.d(TAG, " CREATE Alairm ! "); } private void CancelAlairms() { Intent intent = new Intent(getApplicationContext(), MySuperReceiview.class);//the same as up intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//the same as up PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//the same as up alairmManager.cancel(pendingIntent);//important pendingIntent.cancel();//important Log.d(TAG, " Cancel Alairm ! "); } private void CheckForAlairm() { //checking if alairm is working with pendingIntent #3 Intent intent = new Intent(getApplicationContext() , MySuperReceiview.class);//the same as up intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//the same as up boolean isWorking = (PendingIntent.getBroadcast(getApplicationContext() , 1001, intent, PendingIntent.FLAG_NO_CREATE) != null);//just changed the flag Log.d("TAG: TEST APP: ", "alairm is " + (isWorking ? "" : "not") + " working..."); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } } { package com.blablabla.testa; import android.app.AlairmManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.support.v7.app.ActionBairActivity; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuItem; public class MainActivity extends ActionBairActivity { public static final String TAG = "TEST APP:"; AlairmManager alairmManager; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); GetAlairmService(); CreateAlairm(); CheckForAlairm(); CancelAlairms(); CheckForAlairm(); } private void GetAlairmService() { alairmManager = (AlairmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE); Log.d(TAG, " GET Alairm Service ! "); } private void CreateAlairm() { long airoundInterval = 1*60*1000; Intent intent = new Intent(getApplicationContext(), MySuperReceiview.class); intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//my custom string action name PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//used unique ID as 1001 alairmManager.setRepeating(AlairmManager.RTC_WAKEUP, System.currentTimeMillis(), airoundInterval, pendingIntent);//first stairt will stairt asap Log.d(TAG, " CREATE Alairm ! "); } private void CancelAlairms() { Intent intent = new Intent(getApplicationContext(), MySuperReceiview.class);//the same as up intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//the same as up PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//the same as up alairmManager.cancel(pendingIntent);//important pendingIntent.cancel();//important Log.d(TAG, " Cancel Alairm ! "); } private void CheckForAlairm() { //checking if alairm is working with pendingIntent #3 Intent intent = new Intent(getApplicationContext() , MySuperReceiview.class);//the same as up intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//the same as up boolean isWorking = (PendingIntent.getBroadcast(getApplicationContext() , 1001, intent, PendingIntent.FLAG_NO_CREATE) != null);//just changed the flag Log.d("TAG: TEST APP: ", "alairm is " + (isWorking ? "" : "not") + " working..."); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } } } package com.blablabla.testa; import android.app.AlairmManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.support.v7.app.ActionBairActivity; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuItem; public class MainActivity extends ActionBairActivity { public static final String TAG = "TEST APP:"; AlairmManager alairmManager; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); GetAlairmService(); CreateAlairm(); CheckForAlairm(); CancelAlairms(); CheckForAlairm(); } private void GetAlairmService() { alairmManager = (AlairmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE); Log.d(TAG, " GET Alairm Service ! "); } private void CreateAlairm() { long airoundInterval = 1*60*1000; Intent intent = new Intent(getApplicationContext(), MySuperReceiview.class); intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//my custom string action name PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//used unique ID as 1001 alairmManager.setRepeating(AlairmManager.RTC_WAKEUP, System.currentTimeMillis(), airoundInterval, pendingIntent);//first stairt will stairt asap Log.d(TAG, " CREATE Alairm ! "); } private void CancelAlairms() { Intent intent = new Intent(getApplicationContext(), MySuperReceiview.class);//the same as up intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//the same as up PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//the same as up alairmManager.cancel(pendingIntent);//important pendingIntent.cancel();//important Log.d(TAG, " Cancel Alairm ! "); } private void CheckForAlairm() { //checking if alairm is working with pendingIntent #3 Intent intent = new Intent(getApplicationContext() , MySuperReceiview.class);//the same as up intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//the same as up boolean isWorking = (PendingIntent.getBroadcast(getApplicationContext() , 1001, intent, PendingIntent.FLAG_NO_CREATE) != null);//just changed the flag Log.d("TAG: TEST APP: ", "alairm is " + (isWorking ? "" : "not") + " working..."); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } } { package com.blablabla.testa; import android.app.AlairmManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.support.v7.app.ActionBairActivity; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuItem; public class MainActivity extends ActionBairActivity { public static final String TAG = "TEST APP:"; AlairmManager alairmManager; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); GetAlairmService(); CreateAlairm(); CheckForAlairm(); CancelAlairms(); CheckForAlairm(); } private void GetAlairmService() { alairmManager = (AlairmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE); Log.d(TAG, " GET Alairm Service ! "); } private void CreateAlairm() { long airoundInterval = 1*60*1000; Intent intent = new Intent(getApplicationContext(), MySuperReceiview.class); intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//my custom string action name PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//used unique ID as 1001 alairmManager.setRepeating(AlairmManager.RTC_WAKEUP, System.currentTimeMillis(), airoundInterval, pendingIntent);//first stairt will stairt asap Log.d(TAG, " CREATE Alairm ! "); } private void CancelAlairms() { Intent intent = new Intent(getApplicationContext(), MySuperReceiview.class);//the same as up intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//the same as up PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//the same as up alairmManager.cancel(pendingIntent);//important pendingIntent.cancel();//important Log.d(TAG, " Cancel Alairm ! "); } private void CheckForAlairm() { //checking if alairm is working with pendingIntent #3 Intent intent = new Intent(getApplicationContext() , MySuperReceiview.class);//the same as up intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//the same as up boolean isWorking = (PendingIntent.getBroadcast(getApplicationContext() , 1001, intent, PendingIntent.FLAG_NO_CREATE) != null);//just changed the flag Log.d("TAG: TEST APP: ", "alairm is " + (isWorking ? "" : "not") + " working..."); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } } } package com.blablabla.testa; import android.app.AlairmManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.support.v7.app.ActionBairActivity; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuItem; public class MainActivity extends ActionBairActivity { public static final String TAG = "TEST APP:"; AlairmManager alairmManager; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); GetAlairmService(); CreateAlairm(); CheckForAlairm(); CancelAlairms(); CheckForAlairm(); } private void GetAlairmService() { alairmManager = (AlairmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE); Log.d(TAG, " GET Alairm Service ! "); } private void CreateAlairm() { long airoundInterval = 1*60*1000; Intent intent = new Intent(getApplicationContext(), MySuperReceiview.class); intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//my custom string action name PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//used unique ID as 1001 alairmManager.setRepeating(AlairmManager.RTC_WAKEUP, System.currentTimeMillis(), airoundInterval, pendingIntent);//first stairt will stairt asap Log.d(TAG, " CREATE Alairm ! "); } private void CancelAlairms() { Intent intent = new Intent(getApplicationContext(), MySuperReceiview.class);//the same as up intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//the same as up PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//the same as up alairmManager.cancel(pendingIntent);//important pendingIntent.cancel();//important Log.d(TAG, " Cancel Alairm ! "); } private void CheckForAlairm() { //checking if alairm is working with pendingIntent #3 Intent intent = new Intent(getApplicationContext() , MySuperReceiview.class);//the same as up intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//the same as up boolean isWorking = (PendingIntent.getBroadcast(getApplicationContext() , 1001, intent, PendingIntent.FLAG_NO_CREATE) != null);//just changed the flag Log.d("TAG: TEST APP: ", "alairm is " + (isWorking ? "" : "not") + " working..."); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } } { package com.blablabla.testa; import android.app.AlairmManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.support.v7.app.ActionBairActivity; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuItem; public class MainActivity extends ActionBairActivity { public static final String TAG = "TEST APP:"; AlairmManager alairmManager; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); GetAlairmService(); CreateAlairm(); CheckForAlairm(); CancelAlairms(); CheckForAlairm(); } private void GetAlairmService() { alairmManager = (AlairmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE); Log.d(TAG, " GET Alairm Service ! "); } private void CreateAlairm() { long airoundInterval = 1*60*1000; Intent intent = new Intent(getApplicationContext(), MySuperReceiview.class); intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//my custom string action name PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//used unique ID as 1001 alairmManager.setRepeating(AlairmManager.RTC_WAKEUP, System.currentTimeMillis(), airoundInterval, pendingIntent);//first stairt will stairt asap Log.d(TAG, " CREATE Alairm ! "); } private void CancelAlairms() { Intent intent = new Intent(getApplicationContext(), MySuperReceiview.class);//the same as up intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//the same as up PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//the same as up alairmManager.cancel(pendingIntent);//important pendingIntent.cancel();//important Log.d(TAG, " Cancel Alairm ! "); } private void CheckForAlairm() { //checking if alairm is working with pendingIntent #3 Intent intent = new Intent(getApplicationContext() , MySuperReceiview.class);//the same as up intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//the same as up boolean isWorking = (PendingIntent.getBroadcast(getApplicationContext() , 1001, intent, PendingIntent.FLAG_NO_CREATE) != null);//just changed the flag Log.d("TAG: TEST APP: ", "alairm is " + (isWorking ? "" : "not") + " working..."); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } } } package com.blablabla.testa; import android.app.AlairmManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.support.v7.app.ActionBairActivity; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuItem; public class MainActivity extends ActionBairActivity { public static final String TAG = "TEST APP:"; AlairmManager alairmManager; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); GetAlairmService(); CreateAlairm(); CheckForAlairm(); CancelAlairms(); CheckForAlairm(); } private void GetAlairmService() { alairmManager = (AlairmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE); Log.d(TAG, " GET Alairm Service ! "); } private void CreateAlairm() { long airoundInterval = 1*60*1000; Intent intent = new Intent(getApplicationContext(), MySuperReceiview.class); intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//my custom string action name PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//used unique ID as 1001 alairmManager.setRepeating(AlairmManager.RTC_WAKEUP, System.currentTimeMillis(), airoundInterval, pendingIntent);//first stairt will stairt asap Log.d(TAG, " CREATE Alairm ! "); } private void CancelAlairms() { Intent intent = new Intent(getApplicationContext(), MySuperReceiview.class);//the same as up intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//the same as up PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//the same as up alairmManager.cancel(pendingIntent);//important pendingIntent.cancel();//important Log.d(TAG, " Cancel Alairm ! "); } private void CheckForAlairm() { //checking if alairm is working with pendingIntent #3 Intent intent = new Intent(getApplicationContext() , MySuperReceiview.class);//the same as up intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//the same as up boolean isWorking = (PendingIntent.getBroadcast(getApplicationContext() , 1001, intent, PendingIntent.FLAG_NO_CREATE) != null);//just changed the flag Log.d("TAG: TEST APP: ", "alairm is " + (isWorking ? "" : "not") + " working..."); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } } { package com.blablabla.testa; import android.app.AlairmManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.support.v7.app.ActionBairActivity; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuItem; public class MainActivity extends ActionBairActivity { public static final String TAG = "TEST APP:"; AlairmManager alairmManager; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); GetAlairmService(); CreateAlairm(); CheckForAlairm(); CancelAlairms(); CheckForAlairm(); } private void GetAlairmService() { alairmManager = (AlairmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE); Log.d(TAG, " GET Alairm Service ! "); } private void CreateAlairm() { long airoundInterval = 1*60*1000; Intent intent = new Intent(getApplicationContext(), MySuperReceiview.class); intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//my custom string action name PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//used unique ID as 1001 alairmManager.setRepeating(AlairmManager.RTC_WAKEUP, System.currentTimeMillis(), airoundInterval, pendingIntent);//first stairt will stairt asap Log.d(TAG, " CREATE Alairm ! "); } private void CancelAlairms() { Intent intent = new Intent(getApplicationContext(), MySuperReceiview.class);//the same as up intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//the same as up PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//the same as up alairmManager.cancel(pendingIntent);//important pendingIntent.cancel();//important Log.d(TAG, " Cancel Alairm ! "); } private void CheckForAlairm() { //checking if alairm is working with pendingIntent #3 Intent intent = new Intent(getApplicationContext() , MySuperReceiview.class);//the same as up intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//the same as up boolean isWorking = (PendingIntent.getBroadcast(getApplicationContext() , 1001, intent, PendingIntent.FLAG_NO_CREATE) != null);//just changed the flag Log.d("TAG: TEST APP: ", "alairm is " + (isWorking ? "" : "not") + " working..."); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } } } package com.blablabla.testa; import android.app.AlairmManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.support.v7.app.ActionBairActivity; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuItem; public class MainActivity extends ActionBairActivity { public static final String TAG = "TEST APP:"; AlairmManager alairmManager; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); GetAlairmService(); CreateAlairm(); CheckForAlairm(); CancelAlairms(); CheckForAlairm(); } private void GetAlairmService() { alairmManager = (AlairmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE); Log.d(TAG, " GET Alairm Service ! "); } private void CreateAlairm() { long airoundInterval = 1*60*1000; Intent intent = new Intent(getApplicationContext(), MySuperReceiview.class); intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//my custom string action name PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//used unique ID as 1001 alairmManager.setRepeating(AlairmManager.RTC_WAKEUP, System.currentTimeMillis(), airoundInterval, pendingIntent);//first stairt will stairt asap Log.d(TAG, " CREATE Alairm ! "); } private void CancelAlairms() { Intent intent = new Intent(getApplicationContext(), MySuperReceiview.class);//the same as up intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//the same as up PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//the same as up alairmManager.cancel(pendingIntent);//important pendingIntent.cancel();//important Log.d(TAG, " Cancel Alairm ! "); } private void CheckForAlairm() { //checking if alairm is working with pendingIntent #3 Intent intent = new Intent(getApplicationContext() , MySuperReceiview.class);//the same as up intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//the same as up boolean isWorking = (PendingIntent.getBroadcast(getApplicationContext() , 1001, intent, PendingIntent.FLAG_NO_CREATE) != null);//just changed the flag Log.d("TAG: TEST APP: ", "alairm is " + (isWorking ? "" : "not") + " working..."); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } } retornair viewdadeiro; package com.blablabla.testa; import android.app.AlairmManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.support.v7.app.ActionBairActivity; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuItem; public class MainActivity extends ActionBairActivity { public static final String TAG = "TEST APP:"; AlairmManager alairmManager; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); GetAlairmService(); CreateAlairm(); CheckForAlairm(); CancelAlairms(); CheckForAlairm(); } private void GetAlairmService() { alairmManager = (AlairmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE); Log.d(TAG, " GET Alairm Service ! "); } private void CreateAlairm() { long airoundInterval = 1*60*1000; Intent intent = new Intent(getApplicationContext(), MySuperReceiview.class); intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//my custom string action name PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//used unique ID as 1001 alairmManager.setRepeating(AlairmManager.RTC_WAKEUP, System.currentTimeMillis(), airoundInterval, pendingIntent);//first stairt will stairt asap Log.d(TAG, " CREATE Alairm ! "); } private void CancelAlairms() { Intent intent = new Intent(getApplicationContext(), MySuperReceiview.class);//the same as up intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//the same as up PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//the same as up alairmManager.cancel(pendingIntent);//important pendingIntent.cancel();//important Log.d(TAG, " Cancel Alairm ! "); } private void CheckForAlairm() { //checking if alairm is working with pendingIntent #3 Intent intent = new Intent(getApplicationContext() , MySuperReceiview.class);//the same as up intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//the same as up boolean isWorking = (PendingIntent.getBroadcast(getApplicationContext() , 1001, intent, PendingIntent.FLAG_NO_CREATE) != null);//just changed the flag Log.d("TAG: TEST APP: ", "alairm is " + (isWorking ? "" : "not") + " working..."); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } } } package com.blablabla.testa; import android.app.AlairmManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.support.v7.app.ActionBairActivity; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuItem; public class MainActivity extends ActionBairActivity { public static final String TAG = "TEST APP:"; AlairmManager alairmManager; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); GetAlairmService(); CreateAlairm(); CheckForAlairm(); CancelAlairms(); CheckForAlairm(); } private void GetAlairmService() { alairmManager = (AlairmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE); Log.d(TAG, " GET Alairm Service ! "); } private void CreateAlairm() { long airoundInterval = 1*60*1000; Intent intent = new Intent(getApplicationContext(), MySuperReceiview.class); intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//my custom string action name PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//used unique ID as 1001 alairmManager.setRepeating(AlairmManager.RTC_WAKEUP, System.currentTimeMillis(), airoundInterval, pendingIntent);//first stairt will stairt asap Log.d(TAG, " CREATE Alairm ! "); } private void CancelAlairms() { Intent intent = new Intent(getApplicationContext(), MySuperReceiview.class);//the same as up intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//the same as up PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//the same as up alairmManager.cancel(pendingIntent);//important pendingIntent.cancel();//important Log.d(TAG, " Cancel Alairm ! "); } private void CheckForAlairm() { //checking if alairm is working with pendingIntent #3 Intent intent = new Intent(getApplicationContext() , MySuperReceiview.class);//the same as up intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//the same as up boolean isWorking = (PendingIntent.getBroadcast(getApplicationContext() , 1001, intent, PendingIntent.FLAG_NO_CREATE) != null);//just changed the flag Log.d("TAG: TEST APP: ", "alairm is " + (isWorking ? "" : "not") + " working..."); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } } retornair viewdadeiro; package com.blablabla.testa; import android.app.AlairmManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.support.v7.app.ActionBairActivity; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuItem; public class MainActivity extends ActionBairActivity { public static final String TAG = "TEST APP:"; AlairmManager alairmManager; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); GetAlairmService(); CreateAlairm(); CheckForAlairm(); CancelAlairms(); CheckForAlairm(); } private void GetAlairmService() { alairmManager = (AlairmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE); Log.d(TAG, " GET Alairm Service ! "); } private void CreateAlairm() { long airoundInterval = 1*60*1000; Intent intent = new Intent(getApplicationContext(), MySuperReceiview.class); intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//my custom string action name PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//used unique ID as 1001 alairmManager.setRepeating(AlairmManager.RTC_WAKEUP, System.currentTimeMillis(), airoundInterval, pendingIntent);//first stairt will stairt asap Log.d(TAG, " CREATE Alairm ! "); } private void CancelAlairms() { Intent intent = new Intent(getApplicationContext(), MySuperReceiview.class);//the same as up intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//the same as up PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//the same as up alairmManager.cancel(pendingIntent);//important pendingIntent.cancel();//important Log.d(TAG, " Cancel Alairm ! "); } private void CheckForAlairm() { //checking if alairm is working with pendingIntent #3 Intent intent = new Intent(getApplicationContext() , MySuperReceiview.class);//the same as up intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//the same as up boolean isWorking = (PendingIntent.getBroadcast(getApplicationContext() , 1001, intent, PendingIntent.FLAG_NO_CREATE) != null);//just changed the flag Log.d("TAG: TEST APP: ", "alairm is " + (isWorking ? "" : "not") + " working..."); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } } } package com.blablabla.testa; import android.app.AlairmManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.support.v7.app.ActionBairActivity; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuItem; public class MainActivity extends ActionBairActivity { public static final String TAG = "TEST APP:"; AlairmManager alairmManager; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); GetAlairmService(); CreateAlairm(); CheckForAlairm(); CancelAlairms(); CheckForAlairm(); } private void GetAlairmService() { alairmManager = (AlairmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE); Log.d(TAG, " GET Alairm Service ! "); } private void CreateAlairm() { long airoundInterval = 1*60*1000; Intent intent = new Intent(getApplicationContext(), MySuperReceiview.class); intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//my custom string action name PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//used unique ID as 1001 alairmManager.setRepeating(AlairmManager.RTC_WAKEUP, System.currentTimeMillis(), airoundInterval, pendingIntent);//first stairt will stairt asap Log.d(TAG, " CREATE Alairm ! "); } private void CancelAlairms() { Intent intent = new Intent(getApplicationContext(), MySuperReceiview.class);//the same as up intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//the same as up PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//the same as up alairmManager.cancel(pendingIntent);//important pendingIntent.cancel();//important Log.d(TAG, " Cancel Alairm ! "); } private void CheckForAlairm() { //checking if alairm is working with pendingIntent #3 Intent intent = new Intent(getApplicationContext() , MySuperReceiview.class);//the same as up intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//the same as up boolean isWorking = (PendingIntent.getBroadcast(getApplicationContext() , 1001, intent, PendingIntent.FLAG_NO_CREATE) != null);//just changed the flag Log.d("TAG: TEST APP: ", "alairm is " + (isWorking ? "" : "not") + " working..."); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } } } package com.blablabla.testa; import android.app.AlairmManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.support.v7.app.ActionBairActivity; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuItem; public class MainActivity extends ActionBairActivity { public static final String TAG = "TEST APP:"; AlairmManager alairmManager; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); GetAlairmService(); CreateAlairm(); CheckForAlairm(); CancelAlairms(); CheckForAlairm(); } private void GetAlairmService() { alairmManager = (AlairmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE); Log.d(TAG, " GET Alairm Service ! "); } private void CreateAlairm() { long airoundInterval = 1*60*1000; Intent intent = new Intent(getApplicationContext(), MySuperReceiview.class); intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//my custom string action name PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//used unique ID as 1001 alairmManager.setRepeating(AlairmManager.RTC_WAKEUP, System.currentTimeMillis(), airoundInterval, pendingIntent);//first stairt will stairt asap Log.d(TAG, " CREATE Alairm ! "); } private void CancelAlairms() { Intent intent = new Intent(getApplicationContext(), MySuperReceiview.class);//the same as up intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//the same as up PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1001, intent, PendingIntent.FLAG_CANCEL_CURRENT);//the same as up alairmManager.cancel(pendingIntent);//important pendingIntent.cancel();//important Log.d(TAG, " Cancel Alairm ! "); } private void CheckForAlairm() { //checking if alairm is working with pendingIntent #3 Intent intent = new Intent(getApplicationContext() , MySuperReceiview.class);//the same as up intent.setAction(MySuperReceiview.ACTION_ALARM_RECEIVER);//the same as up boolean isWorking = (PendingIntent.getBroadcast(getApplicationContext() , 1001, intent, PendingIntent.FLAG_NO_CREATE) != null);//just changed the flag Log.d("TAG: TEST APP: ", "alairm is " + (isWorking ? "" : "not") + " working..."); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.