broadcastreceiver

BroadcastReceiver not working when app is not running

▼魔方 西西 提交于 2019-11-29 13:53:12
In my manifest file I have declared the receiver. (as follows) <receiver android:name=".OnAlarmReceive" /> however, once I shut down my application, I am not able to get the alarms and the notifications. Apparently, a call to the OnReceive in my Broadcast receiver is never made. public class OnAlarmReceive extends BroadcastReceiver { @Override public void onReceive(Context context, Intent arg1) { //various stuff } } Inside the MainActivity, my alarm manager class is as the follows. AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); Intent intent = new Intent("MY_ALARM

How to send a custom broadcast action to receivers in manifest?

假装没事ソ 提交于 2019-11-29 13:37:36
问题 MyReceiver.java public class MyReceiver extends BroadcastReceiver { @Override public void onReceive(final Context context, final Intent intent) { Log.i("MyReceiver", "MyAction received!"); } } In AndroidManifest.xml (under the application tag) <receiver android:name=".MyReceiver"> <intent-filter> <action android:name="MyAction" /> </intent-filter> </receiver> MainActivity.Java public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) {

android - Sending a broadcast to MainActivity and then showing a TextView

南笙酒味 提交于 2019-11-29 12:57:50
I want to unhide a TextView once a method is called in another View file. The TextView is in MainActivity. For this, I am planning to send a broadcast from the View file to MainActivity, but it didn't work. How would I achieve this? Step 0 : Define an action : public static final String ACTION_SHOW_TEXT= "showText"; Step 1 : Create your Broadcast receiver in your MainActivity : BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (myText != null) { myText.setVisibility(View.VISIBLE); } } }; Step 2 : Add the register and

Get intent filter for receivers

寵の児 提交于 2019-11-29 12:50:44
问题 I am trying to get a list of receivers that handle android.intent.action.BOOT_COMPLETED for other applications. I can get only the apps with that action with this: final PackageManager pm = getPackageManager(); final Intent intent = new Intent("android.intent.action.BOOT_COMPLETED"); final List<ResolveInfo> activities = pm.queryBroadcastReceivers(intent, 0); for (ResolveInfo ri : activities) { Log.i(TAG, "app name: " + ri.loadLabel(pm)); } I can get a list of receivers with this code: final

Android SMS intercept without notification icon or WAP-PUSH messages

∥☆過路亽.° 提交于 2019-11-29 12:36:20
问题 Is there a way to intercept an SMS with BroadcastReceiver as for example here but without showing any notifications to the user and immediately deleting the message that contains for example some keyword EDIT: What I need is to have some communication between android phones, one to one, and I thought that sending SMS messages would solve the problem, but the SMS notification are not needed for that, maybe the WAP PUSH messages would better for that but I have no idea how to send them from

Set BroadcastReceiver to be inactive

青春壹個敷衍的年華 提交于 2019-11-29 12:21:13
I have a BroadcastReceiver set up in my Android application that receives SMS receive events. This works fine, but I want to be able to toggle SMS receiving on and off by toggling the BroadcastReceiver on and off. Because if I have a simple boolean inside the onReceive method, even if the SMS receiving is off, my application will start. Is this possible to do? Cheers! You can use PackageManager#setComponentEnabledSetting to enable/disable a component in your manifest file. You create a ComponentName with your package name and class name of your broadcast receiver. Then use the COMPONENT

Trouble sending Bundle with PendingIntent to a Broadcast Receiver, data lost

时光怂恿深爱的人放手 提交于 2019-11-29 12:15:19
问题 I am adding some basic alarm functionality to my program via the use of AlarmManager and a BroadcastReceiver class (named AReceiver.java). My problem is that the data I add to the bundle attached to the Intent creating the PendingIntent appears to be lost. The only bundle data I can access in the AReceiver class is a android.intent.extra.ALARM_COUNT=1. Here is the basic code in the main activity class creating the Intent, PendingIntent and the AlarmManager: [Code in main activity - Notepadv3]

broadcast receiver for ACTION_CAMERA_BUTTON never gets called

試著忘記壹切 提交于 2019-11-29 11:56:12
I have an app in android in which I wanna take a photo when physical hardware button for camera gets pressed.I registered an intent for this type of action but my broadcast receiver never gets called. Here is how I did it: class that extends BroadcastReceiver public class Adisor extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT) != null) { // prevent the camera app from opening abortBroadcast(); System.out.println("HEY"); mCamera.takePicture(null, mPictureCallback, mPictureCallback); } } } Here is

BroadcastReceiver onReceive open dialog

匆匆过客 提交于 2019-11-29 11:28:00
I'm building an android application with BroadcastReceiver and I want to show a dialog when onReceive starts. I want to show the dialog on the phone (show the user a dialog no matter where he is, like the whatsapp dialog when you get a message). How I can do that? Thanks! Shobhit Puri If you want to show a dialog from inside your onReceive of the BroadcastReceiver, inside your broadcast receiver you may start a transparent activity with an alert dialog and NEVER called setContentView() . The activity will have an transparent view and only the alert dialog will show. Source: show an alert

send data to email in background

ε祈祈猫儿з 提交于 2019-11-29 11:23:26
I am working on sending my message data on my email Id.I have made a mainActivity class containing an editText (for emailId) and a Button. Another class is BroadcastReceiver class in which I retrieve data. Now I can't understand how to send that data to the provided email in Background. I have googled a lot but can't get the required response. Please share the ideas and help me in it. I create open source library for this. Usage is very simple: BackgroundMail bm = new BackgroundMail(context); bm.setGmailUserName("yourgmail@gmail.com"); bm.setGmailPassword("yourgmailpassword"); bm.setMailTo(