broadcastreceiver

setPackage for intent in gingerbread

↘锁芯ラ 提交于 2019-11-29 11:14:38
According to the android documentation : Alternatively, starting with ICE_CREAM_SANDWICH, you can also safely restrict the broadcast to a single application with Intent.setPackage Is there any way in Gingerbread (using the compatibility library perhaps) to restrict a sendBroadcat() event such that it only sends it to a specified package? My first suggestion would be to use LocalBroadcastManager if at all possible. This allows you to completely ignore any security issues. If you really do need to send the broadcast from one app to another, it is indeed true that registerReceiver() did not

Start application without activity, my Broadcast Receiver not work

霸气de小男生 提交于 2019-11-29 10:54:26
In my app, I have a Broadcast Receiver for catching the message sent to my phone <receiver android:name="com.qmobile.ows.SMS_Receiver" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="android.intent.action.PHONE_STATE" /> <action android:name="android.provider.Telephony.SMS_RECEIVED" /> </intent-filter> </receiver> If I start app with activity GUI, the BroadCast Receiver works normally. I want to start my application without activity and do not show icon app, so I remove this code below from my activity <intent-filter> <action android:name="android.intent

Incoming call broadcast receiver not working (Android 4.1)

孤街醉人 提交于 2019-11-29 10:54:23
I'm trying to catch an incomming call broadcast but it isn't working. This is my manifest: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.test.bgPicture" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="9" /> <uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /

Run service on incoming SMS in android Oreo

末鹿安然 提交于 2019-11-29 10:46:13
I'm developing an app which needs to run some code (Networking) whenever an SMS is received. In API 25 and lower it's fine, I register an implicit receiver in Manifest file and start my service in the specified class which extended BroadcastReceiver . In API 26 however you cannot register android.provider.Telephony.SMS_RECEIVED in a receiver since it won't work. From Android documentation: Note: If your app targets API level 26 or higher, you cannot use the manifest to declare a receiver for implicit broadcasts (broadcasts that do not target your app specifically), except for a few implicit

Is there any reason to continue using IntentService for handling GCM messages?

五迷三道 提交于 2019-11-29 10:24:35
As you know, recently Google changed their GCM documentation, and they claim that an IntentService is no longer required for handling arriving GCM messages. All the handling can be done in the BroadcastReceiver . When trying to figure out if there is any good reason to continue using the IntentService , I came across this quote : A Service (typically an IntentService) to which the WakefulBroadcastReceiver passes off the work of handling the GCM message, while ensuring that the device does not go back to sleep in the process. Including an IntentService is optional —you could choose to process

SMS Received in my SMS app and in Hangouts, although I call abortBroadcast()

南楼画角 提交于 2019-11-29 10:18:34
问题 I have an SMS blocker Android application developed myself which was working quite well capturing all the spams until recently Google updated its Hangouts app to work with SMSs. The Problem: SMS is getting captured by both my app and hangouts! Even though the message is blocked by my app and stored in its private database, it is also present in the hangouts app and thus in the stock Messaging app at the same time. Seems the abortBroadcast() isn't working any more. Everything was working

On which thread does onReceive() of a BroacastReceiver registered with LocalBroadcastManager run?

*爱你&永不变心* 提交于 2019-11-29 09:42:39
I register a broadcast receiver in a preference activity and send it a (sync) broadcast from a (Wakeful) IntentService. Apparently onReceive runs on the service's thread. Is this a fault of my part ? Is it documented behavior ? Preference activity: public final class SettingsActivity extends BaseSettings { private static CharSequence sMasterKey; private CheckBoxPreference mMasterPref; // Receiver /** If the master preference is changed externally this reacts */ private BroadcastReceiver mExternalChangeReceiver = new ExternalChangeReceiver(); public static void notifyMonitoringStateChange

Broadcasting and receiving extra doubles

 ̄綄美尐妖づ 提交于 2019-11-29 08:59:37
I'm attempting to broadcast extras in an am broadcast in adb shell. In my BroadcastReceiver in android, I'm subscribed to the broadcast and pull the extras out of the Bundle. My trouble lies with doubles. I assumed that a broadcast could include a double since the Bundle class has a getDouble method, e.g.: double percentComplete = bundle.getDouble("percent_complete"); However, the am broadcast command in adb shell doesn't seem to support doubles, only floats. When I send the float, the Bundle.getDouble() method throws an internal exception, logged at the warning level, indicating that it fails

Widget sending multiple types of intents

让人想犯罪 __ 提交于 2019-11-29 08:48:21
I am building a widget that has multiple buttons, each one sending off its own intent to a broadcast receiver. The broadcast receiver is suppose to display a Toast message based on which button was pushed. The code currently looks like this: public class WidgetProvider extends AppWidgetProvider { @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds){ ComponentName thisWidget = new ComponentName(context, WidgetProvider.class); int[] allWidgetIds = appWidgetManager.getAppWidgetIds(thisWidget); for (int widgetId : allWidgetIds) { RemoteViews

How to detected if application is closed

穿精又带淫゛_ 提交于 2019-11-29 08:40:59
I have an app that receives from the Broadcastreceiver to fetch new data from the web(json), when my app is running while it fetches; everything runs well, when the app is closed it crashes "Your app stopped working". Even the following good to check if my app is in the foreground doesn't work. i want it so if the app is closed, not running, to call an intent to open the app for it not to crash, so how do I check if application is closed? My code; public class UpdateReceiver extends BroadcastReceiver { private static long alarmTime = 0; @Override public void onReceive(Context context, Intent