broadcastreceiver

Track the launch of a third-party application

你。 提交于 2019-12-25 08:38:32
问题 Is it possible to track the launch of a third-party application on the device? Maybe the android sends a broadcast when the applications are launched. UPDATE public class ServiceAppControl extends IntentService { private boolean serviceStarted = true; public ServiceAppControl() { super("ServiceAppControl"); } @Override protected void onHandleIntent(@Nullable Intent intent) { while (serviceStarted){ String appIsForeground = isAppOnForeground(getBaseContext()); Log.d(AppGlobal.LOG_TAG,

Alarm with broadcast receiver not working on Fragment

旧巷老猫 提交于 2019-12-25 07:58:54
问题 I'm working on a app with Fragments, One of the fragment includes alarm functionality. For this I have used broadcast receiver but don't understand why its not working: Here is the code, I'm working on PC "not a Mobile device" public class SchedulerListFragment extends Fragment { PendingIntent pendingIntent; AlarmManager alarmManager; BroadcastReceiver mReceiver; EditText ethr,etmin,etsec; int result = 1; int hr = 0; int min = 0; int sec = 0; Button alarm; IntentFilter filter1; private void

Problems with BroadcastReceiver and multiple proximity alerts

家住魔仙堡 提交于 2019-12-25 06:52:47
问题 I realize this question already exists, but I am having trouble implementing the solutions. I'm using these questions as guidlines: multiple proximity alert based on a service set 2 proximity alerts with the same broadcast Where I register the receiver: final String NEAR_YOU_INTENT = "neighborhood.crodgers.example.activities.PROXIMITY_ALERT"; IntentFilter filter = new IntentFilter(NEAR_YOU_INTENT); registerReceiver(new LocationReceiver(), filter); Where the proximity alerts are added (Note:

my sms receiver can't accept new sms

本秂侑毒 提交于 2019-12-25 05:28:07
问题 i want to receive sms on my application, but when i try to get new sms my application didn't get the new sms. I cannot find where I am doing wrong. I'm not sure if there's something wrong with the code, or debugging. I'm trying to be notified if a new SMS arrives and save the sms on my database. this is my receiver. public void onReceive( Context c, Intent i) { Bundle b = i.getExtras(); SmsMessage[] m = null; String s = ""; TelephonyManager teleponyManager = (TelephonyManager) c

Access a database from Broadcast receiver?

早过忘川 提交于 2019-12-25 03:56:24
问题 I cant access my SQlite database from my broadcast receiver . Is it even possible? I keep getting a NullPointerException . In the onReceive of the BroadcastReceiver I call mDbHelper = new ResponderDbAdapter(context); mDbHelper.open(); Is it something to do with the context? I want to pull database info that gets set in my MainActivity into the BroadCast Receiver . Ideas? EDIT : ERROR: 07-29 16:43:46.491: ERROR/AndroidRuntime(6772): FATAL EXCEPTION: main 07-29 16:43:46.491: ERROR

Android Broadcast Receiver and Force Close (Uncaught exceptions)

喜夏-厌秋 提交于 2019-12-25 03:53:32
问题 I have a multi Activity application with a quit/logout button on most of the screens. On pressing the button it shows a confirmation dialog and then sends out a 'quit' broadcast. I have a broadcast receiver on each of the activity that simply calls the finish() activity and in the OnDestroy I unregister the receiver. The code works well in normal usage. The issue that I am facing is if an uncaught exception pops up and a Force close happens. After I press OK the last activity shows up. When I

How to edit shared preferences in an activity other than the one it is created in?

微笑、不失礼 提交于 2019-12-25 03:34:49
问题 I have created some shared preference in an activity and I want to modify it in a broadcast reciever...How can I do that??? Please help... I have tried looking but couldn't get the answer 回答1: You should be able to do: SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor edit = prefs.edit(); using the context passed into the BroadcastReceiver. 来源: https://stackoverflow.com/questions/7853564/how-to-edit-shared-preferences-in-an-activity

Google GCM client not sending messages after unregistering/registering the BroadcastReceiver programatically

我的未来我决定 提交于 2019-12-25 03:24:43
问题 I would like to register/unregister the BroadcastReceiver which I am using to receive messages from GCM. I have declared and initialised the BroadcastReceiver.class in my onResume(), but after I unregister inside onPause() next time my app launches it wont send messages any more, only if I send the regId again and register with the GCM server as well. Can the BroadcastReceiver be responsible for not sending the messages? Or is it essential to have the BroadcastReceiver registered in the

Broadcast Receiver does not deduct calls - Android

拈花ヽ惹草 提交于 2019-12-25 03:10:35
问题 I am trying to do some work at incoming call times. I am trying like this public class callDeductor extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE); if(state.equals(TelephonyManager.EXTRA_STATE_RINGING)) { Toast.makeText(context, "Phone Is Ringing", Toast.LENGTH_LONG).show(); } if(state.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) { Toast.makeText(context, "Call Recieved", Toast

Starting an Android notification at startup

人走茶凉 提交于 2019-12-25 03:04:20
问题 This question is based off of this previous question of mine: Android - Set notification to never go away I now realize that I need something to be triggered at startup to trigger the notification. From my previous question, it looks like I can take two routes. Either start a service, or use a BroadcastReceiver. I think that starting a service is a little overkill (but what do I know). I am stuck while going with the BroadcastReceiver route. It works in general, but when I take my code for a