android-broadcastreceiver

Perform long running operations when receiving SMS on API < 21

戏子无情 提交于 2019-12-13 20:24:11
问题 I'm building an app that will listen for incoming SMS messages, perform some potentially long running operations and send back a reply if some conditions are met. I've got the listening part working using a BroadcastReceiver , but I'm not sure how/where to perform the potentially long running operations. The Android Developer Documentation states that After onReceive(), the system can kill the process at any time to reclaim memory, and in doing so, it terminates the spawned thread running in

Get app package name selected by user for sharing using 'Intent.ACTION_SEND'

痴心易碎 提交于 2019-12-13 17:59:50
问题 I am using following code to share text Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.putExtra(Intent.EXTRA_TEXT, "share test"); startActivity(Intent.createChooser(sharingIntent, "Share using")); I want to know package name of the app chosen by user to share. I have tried doing it using IntentSender for 5.1+ devices using following code Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.putExtra(Intent.EXTRA_TEXT,

android getSystemService error with extends BroadcastReceiver

左心房为你撑大大i 提交于 2019-12-13 09:28:50
问题 I have 2 activities public class MainActivity extends AppCompatActivity { .............. @Override protected void onCreate(Bundle savedInstanceState) { .............. .............. } } public class IncomingSms extends BroadcastReceiver{ public void onReceive(Context context, Intent intent){ .............. .............. } public String getCellData() { TelephonyManager telephonyManager = (TelephonyManager) ***getSystemService***(Context.TELEPHONY_SERVICE); GsmCellLocation cellLocation =

automatically sms read not working in android

…衆ロ難τιáo~ 提交于 2019-12-13 09:23:28
问题 public class SmsReceiver extends BroadcastReceiver { private static SmsListener mListener; @Override public void onReceive(Context context, Intent intent) { final Bundle data = intent.getExtras(); final Object[] pdus = (Object[]) data.get("pdus"); for (int i = 0; i < pdus.length; i++) { SmsMessage smsMessage = SmsMessage.createFromPdu((byte[]) pdus[i]); String sender = smsMessage.getDisplayOriginatingAddress(); //You must check here if the sender is your provider and not another one with same

How to stop a running service using broadcast receiver in android

时光总嘲笑我的痴心妄想 提交于 2019-12-13 07:37:33
问题 I think there is a simple problem in my code but I couldn't figure it out. I have a HeaderService which shows a bubble popup over some particular apps. Now what I want is stop that service when user presses Home key or Back key using BroadCastReceiver. Please take a look at my code and suggest me some solution. Thanks in Advance!! This is my Receiver class public class PopupClosingReceiver extends BroadcastReceiver { private boolean isMyServiceRunning(Context con) { ActivityManager manager =

Error: 'Default Activity Not Found' for an app containing a Broadcast receiver

核能气质少年 提交于 2019-12-13 02:56:44
问题 I have two separate apps. The first sends out two different kinds of Broadcasts. The second one waits for this broadcast from App #1 and uses the broadcast to decide what activity to launch. What I'm confused about is this: It seems to me that App #2 (the receiving app) shouldn't necessarily require a default activity since the activity it launches depends on the broadcast received from App #1. But, if a default activity is not defined in App #2, it can't run and throws: Error running app:

Why my BroadcastReceiver stop receiving after a while

荒凉一梦 提交于 2019-12-13 02:24:07
问题 I have a IntentService that does a long work, it takes about 15 minutes to be done. It is a synchronization process to get new data from my server. When this service starts, I start a activity too, to display the progess. This activity creates a BroadcastReceiver , that intercepts messages sent from the service about the process progress. If I leave the app doing it job, after a while the SO switch off the screen. When I switch on the screen again, after about 15 minutes, the service has been

BroadcastReceiver has no internet access

巧了我就是萌 提交于 2019-12-13 01:36:18
问题 I'm facing a problem with my broadcast receiver. I have set an alarm for 6am, it has to fire my broadcast receiver, which only has to download some data from internet and process it. If I set the alarm for 3pm, for example, it works fine. But the problem is at 6am, it fails downloading because it does not have network connectivity. I perform a partial wake lock before attempting download. Can it be related to this? Does the phone enter some deep sleep and partial wake lock is not enough? What

AnalyticsReceiver in Google Analytics Tracking

别来无恙 提交于 2019-12-12 19:42:16
问题 In Google Analytics Tracking Ver1, it has class AnalyticsReceiver . But when I used Google Analytics Tracking Ver2, it hasn't got AnalyticsReceiver class. I don't know which class should I use instead. In manifest declared when use Google Analytics Tracking: <receiver android:name="com.google.analytics.tracking.android.AnalyticsReceiver" android:exported="true" > <intent-filter> <action android:name="com.android.vending.INSTALL_REFERRER" /> </intent-filter> </receiver> Can you help me. 回答1:

How to use MediaSession.setMediaButtonReceiver(PendingIntent) to resume playback

て烟熏妆下的殇ゞ 提交于 2019-12-12 18:15:12
问题 I'm trying to be able to start music playback from my app when the headset buttons are clicked while my app is stopped. I can use MediaSession.Callback onMediaButtonEvent() or the now deprecated registerMediaButtonEventReceiver() to listen for media button click WHILE my app is playing music, but if I pause the music for a minute, with my Activity and playback Service still running, and then I press the headset button, I see that I have lost the ability to receive the media button broadcast.