android-broadcast

Listen to location access disable/enable in settings

两盒软妹~` 提交于 2019-12-09 17:12:13
问题 In Android OS, in " Settings " --> " Location services ", there is a toggle button named " Access to my location " which can be used to disable & enable location info access from apps. Currently, I am developing a location service application. I am wondering, how can I listen to this setting in my Android project? Is there any broadcast receiver I can use to know right away when user disable or enable " Access to my location " ? If there isn't any broadcast receiver for it, how can I listen

Update service running on background

别来无恙 提交于 2019-12-09 13:44:23
问题 I need to implement such a procedure: Start a background service Update the service with parameters (from UI - user input) After activity ended the service should keep on running and preform requests to HTTP server every minute. in this stage i still need the parameters I updated in the second stage - I send them to the server. The service should store the server last response and compere each with the last. if there is a change, notify the user. Finally, when the activity starts again, the

How to check user entered own phone number in EditText?

大城市里の小女人 提交于 2019-12-09 05:23:13
问题 Mobile number will be entered in an edittext by user on registration page in my Android application. How can I check that user entered his/her mobile number not other's ? I've tried this : TelephonyManager tMgr =(TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE); mPhoneNumber = tMgr.getLine1Number(); And compare this variable with edittext's text. But mPhoneNumber returns NULL in my case. Is there any other options? How to solve this ? Any help would be appreciable. I

Listen for new calendar events

和自甴很熟 提交于 2019-12-09 04:24:32
问题 Mainly what I need is to react depending on the events in the default android calendar (Google). It's fairly easy to query the provider and get the events at any given time but my data has to be consistent all the time. What I want is to avoid querying the provider each x min to check for new events. I couldn't find any system broadcast for when the app stores the new event (only when the event gets triggered). Just to be clear, I don't want to create, delete, etc events from my app, I just

Android:Music Player,Unable to start service with null point exception?

百般思念 提交于 2019-12-08 14:04:57
问题 There were no errors until i added broadcast receiver for showing the progress of the seekbar.The app was working fine before. Code for the activity. package source.justanothermusicplayer; import java.io.Serializable; import java.util.ArrayList; import source.justanothermusicplayer.classes.SongDetails; import source.justanothermusicplayer.service.Music_service; import android.app.Activity; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent;

How to remove fragment when I rotate my tablet

流过昼夜 提交于 2019-12-08 12:35:51
问题 I have 2 fragments which are called from the action bar of an activity. Both are gridviews, the first one displays an application list with a dedicated adapter, and the second one displays a file list with another adapter. My problem is that when I launch a file then when I back to my activity I switch from one fragment to another, when I come back to the previous one, its content disappears. And when I rotate tablet I have the some problem, because my Fragment restart so for this I think

How to make Asynctask wait untill GCM Broadcast is received

余生长醉 提交于 2019-12-08 10:15:58
问题 I am using below code to register my device for GCM private class GetGcmRegId extends AsyncTask<Void, Void, String> { @Override protected void onPreExecute() { super.onPreExecute(); pdia = new ProgressDialog(LoginActivity.this); pdia.setMessage("Please Wait..."); pdia.setCancelable(false); pdia.setCanceledOnTouchOutside(false); pdia.show(); } @Override protected String doInBackground(Void... params) { GCMRegistrar.register(LoginActivity.this, Utility.SENDER_ID); regid = GCMRegistrar

BroadCast Reveiver IS counting power button click, but UNABLE to RESUME a minimized activity

隐身守侯 提交于 2019-12-08 05:00:46
问题 In this code : 1.public class MyReceiver extends BroadcastReceiver 2. public class MainActivity extends Activity As my application starts I press the HOME button and MINIMIZE it ! After that the MyRecevier is counting the power button counts which is visible in the LOGCAT, but then MyReceiver is unable to launch (make visible on the screen) that minimized activity i.e. the MAINACTIVITY or any othere new Activity. P.S. I want to launch an activity after certain clicks. MyReceiver.java public

how to register broadcast receiver for low battery in android?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-07 22:51:46
问题 I want to register broadcast for low battery. If battery status reached at some level I want to get alert... Please if you have any idea please help me.. 回答1: You will need to register a BroadcastReceiver for ACTION_BATTERY_LOW. You can do this in the manifest with a <receiver> element or via registerReceiver() from some already-running component of your application. 回答2: For Battery_Status_Low, You could try registering it through a Service for example, like: BatteryReceiver receiver = new

How to broadcast a parcelable object in an intent?

牧云@^-^@ 提交于 2019-12-07 08:42:33
问题 I'm new to Java / Android and trying to develop an adroid application which communicates with a USB CAN Bus adapter. I receive messages from the adapter in a string via my CANBusController class and I have built a parcelable class, CANMessage, which converts the string received into a form I can use (int Id, int Length, byte[] data). Now I'm trying to display the message I have received. I have a Fragment, CANBusControlFragment, which declares a BroadcastReceiver. When a message is a received