broadcastreceiver

Android Broadcast Receiver Error: Class not found exception

旧巷老猫 提交于 2019-11-30 05:39:35
问题 I have a Broadcast receiver setup so that a pop-up message is displayed to the user after each upgrade of my app, or if this is the first time the package is installed. I tested this on my Droid running Android 2.2 both as a fresh install and after upgrading my app, as well in the Emulator running 1.5 and 1.6, and I see everything run fine. However, I received an error report from a user that lists the following exception: java.lang.RuntimeException: Unable to instantiate receiver com.name

Emulate a broadcast in Android

那年仲夏 提交于 2019-11-30 05:17:33
问题 I need to know how to emulate a broadcastreceiver . I have the following code, but I have no clue how to actually see when it is receiving a broadcast. public class LocationBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Bundle b = intent.getExtras(); Location loc = (Location)b.get(android.location.LocationManager.KEY_LOCATION_CHANGED); Toast.makeText(context, loc.toString(), Toast.LENGTH_SHORT).show(); Log.d("com.dennis.test",

How to check if Pending intent triggered by AlarmManager setRepeating is already running?

 ̄綄美尐妖づ 提交于 2019-11-30 05:13:09
I would be glad to know how to check if Pending intent which is triggered by an Alarm Manager which starts an activity at a specific time given by AlarmManager.setRepeating? To be more specific , I have an activity which kicks off another activity with a paticular set time, or repeating time, (which works) . But i want to know if the request was already set by the user? in that case i should not start certain values. This is how i start the scheduled activity. Intent myIntent = new Intent(getBaseContext(),MyScheduledReceiver.class); PendingIntent pendingIntent = PendingIntent.getBroadcast

Android App A wants to track Google Play referral data for Android App B installation

大憨熊 提交于 2019-11-30 05:03:51
Let's say I have an Android App A that is installed in the user's device and I have an AppWidget with my App where we let other Android developers publish their App promotion ads on a Cost Per Install basis. So we need to track if App B is being installed on the user's device through App A's referral. Let's also assume Android App B has its advertisement running on Android App A's widget and the link through which we redirect App A's users to App B's user to Google Play is with all referrer data. The URL looks like this (as recommended here - https://play.google.com/store/apps/details?id=com

Implement Broadcast receiver inside a Service

拥有回忆 提交于 2019-11-30 04:55:26
问题 I want to check Internet connection throughout the run time of my Android application. I tried using services but seems like it is not the best option. Is there any possible way for me to implement a broadcast receiver with in a service? Or do I have to give up the service and use broadcast receivers alone? 回答1: I now show how to create SMS receiver in a service: public class MyService extends Service { @Override public void onCreate() { BwlLog.begin(TAG); super.onCreate(); SMSreceiver

BroadcastReceiver for CONNECTIVITY_ACTION always returns null in intent.getExtras()

删除回忆录丶 提交于 2019-11-30 04:09:46
Im trying to receive BroadcastMessages from CONNECTIVITY_ACTION: // register BroadcastReceiver on network state changes final IntentFilter mIFNetwork = new IntentFilter(); mIFNetwork.addAction(android.net.ConnectivityManager.CONNECTIVITY_ACTION); //"android.net.conn.CONNECTIVITY_CHANGE" registerReceiver(mIRNetwork, mIFNetwork); and receiver is: private BroadcastReceiver mIRNetwork = new BroadcastReceiver() { @Override public void onReceive(final Context context, final Intent intent) { android.util.Log.i(TAG,"mIRNetwork: Network State Received: "+intent.getAction()); Bundle extras = intent

Starting Service from BroadcastReceiver

穿精又带淫゛_ 提交于 2019-11-30 04:09:29
I have a Service and BroadcastReceiver in my application, but how do I launch the service directly from the BroadcastReceiver ? Using startService(new Intent(this, MyService.class)); does not work in a BroadcastReceiver , any ideas? EDIT: context.startService(..); works, I forgot the context part Don't forget context.startService(..); should be like that: Intent i = new Intent(context, YourServiceName.class); context.startService(i); be sure to add the service to manifest.xml use the context from the onReceive method of your BroadcastReceiver to start your service component. @Override public

PACKAGE_ADDED BroadcastReceiver doesn't work

自闭症网瘾萝莉.ら 提交于 2019-11-30 03:58:58
I have a broadcast receiver registered in Manifest: <application ...> <receiver android:name="com.some.pkg.NewAppReceiver" > <intent-filter> <action android:name="android.intent.action.PACKAGE_ADDED" /> </intent-filter> </receiver> </appcication> And the receiver: public class NewAppReceiver extends BroadcastReceiver { private static final String TAG = "NewAppReceiver"; @Override public void onReceive(Context context, Intent intent) { Log.d(TAG, "Intent: " + intent.getAction()); } } And nothing is received when I install APK manually or from the Android Market . Why? Did you run the app that

How to send data through PendingIntent to Broadcast?

 ̄綄美尐妖づ 提交于 2019-11-30 03:57:38
I'm trying to send via PendingIntent some extra data, like: MyMessage message; //... Intent intent; SmsManager sms = SmsManager.getDefault(); intent = new Intent(Constants.SENT_PLAIN); intent.putExtra(Constants.EXTRA_RAW_ID, message.getId()); //putting long id (not -1L) PendingIntent sentPI = PendingIntent.getBroadcast(activity, 0, intent, 0); intent = new Intent(Constants.DELIVERED_PLAIN); intent.putExtra(Constants.EXTRA_RAW_ID, message.getId()); PendingIntent deliveredPI = PendingIntent.getBroadcast(activity, 0, intent, 0); sms.sendTextMessage(phoneNumber, null, message.getBody(), sentPI,

Android: BroadcastReceiver when insert/remove the device USB plug into/from a USB port

荒凉一梦 提交于 2019-11-30 03:56:59
问题 My application don't catch "ACTION_USB_DEVICE_ATTACHED" but "ACTION_USB_DEVICE_DETACHED" work fine. Application start correctly if I connect usb device but I disconnect during execution BroadcastReceiver right catch "ACTION_USB_DEVICE_DETACHED". If I attach again BroadcastReceiver don't catch anything. IntentFilter filter = new IntentFilter(); filter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED); filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED); rocrailService.registerReceiver