broadcastreceiver

BroadcastReceiver with intent-filter for them?

一笑奈何 提交于 2019-12-01 12:02:46
问题 Her is what I'm trying to accomplish: When user tries to share some text from any app (Like sharing a tweet or a link), my app will appear in the sharing list. If he select my app, some simple code will be run (like showing a Toast) then that's it. No interface or UI is needed. Here is how I did it: AndroidManifest.xml <receiver android:name=".MyBroadcastReceiver" > <intent-filter android:label="select my app"> <action android:name="android.intent.action.SEND" /> <category android:name=

Android - Broadcast Receiver not being fired

强颜欢笑 提交于 2019-12-01 11:42:29
I know this has been asked ALOT on here, but I have been scouring the interwebs for hours and I have even reused some of my previous code for receiving sms' and I got...nothing. So, here goes, basic app to receive SMS but the app never receives the intent. I thought the intent may be ignored if the text is sent from the same phone but that does not seem to be the case, as other apps pick up the text fine. Here is my manifest: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.encima.smsreceiver" android:versionCode="1"

BroadcastReceiver with a Listener drains battery when not in use

半城伤御伤魂 提交于 2019-12-01 11:33:38
问题 I have a receiver which waits for TelephonyManager.ACTION_PHONE_STATE_CHANGED : public void onReceive(Context context, Intent intent) { String theAction = intent.getAction(); if (theAction != null && theAction.equals(TelephonyManager.ACTION_PHONE_STATE_CHANGED)) { CONTEXT = context; startListening(); } When it gets it, I register the listener (for orientation sensor): public void startListening() { sensorManager = (SensorManager) CONTEXT.getSystemService(Context.SENSOR_SERVICE); List<Sensor>

BroadcastReceiver not receiving intent

百般思念 提交于 2019-12-01 11:26:56
So now I have my BroastcastReceiver declared in the manifest file... <receiver android:name=".MyReceiver"> <intent-filter> <action android:name="android.intent.action.CALL_BUTTON" /> </intent-filter> </receiver> I want to catch the intent when the Call button is pressed. Here is my code... public class MyReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Toast.makeText(context, "intent received", Toast.LENGTH_LONG); if(intent.getAction().equals("android.intent.action.CALL_BUTTON")) { Toast.makeText(context, "call button pressed", Toast.LENGTH

“com.android.vending.INSTALL_REFERRER” somehow parameters are lost and changed to (not%20set)

我的未来我决定 提交于 2019-12-01 11:24:52
I have a problem with INSTALL_REFERRER broadcast in my app. I'm trying to create some information about campaign etc, but on most devices my url " https://play.google.com/store/apps/details?id=com.test.apptest&referrer=utm_source%3Dmy_test_source " EDIT: the same thing happens with link "market://details?id=com.test.apptest&referrer=utm_source%3Dmy_test_source" is change to something like "utm_source=(not%20set)&utm_medium=(not%20set)" I don't know what is the reason for such a behaviour of google play store app but maybe someone has deal with that ? EDIT 2: It looks like that it has something

Android, How to receive home button click through broadcast receiver?

▼魔方 西西 提交于 2019-12-01 11:22:43
问题 In my application I need to send log-out request to server when ever user goes out of application via clicking on log-out button or closing application by pressing home button key. There is no problem with button and result is as I expect. The problem is how to get home button. Based on my research it is not possible to use onKeyDown(int keyCode, KeyEvent event) as we can use for getting back button. The solution that I'm thinking about is registering a receiver and sending a broadcast

How can I create a project in Android Studio to function default SMS app

China☆狼群 提交于 2019-12-01 11:22:12
Continuation of the previous query, see: SMS Receiver for AND API 19 and higher I need to make the application run in the background and I could have it after installing the set as a default as shown here: http://android-developers.blogspot.cz/2013/10/getting-your-sms-apps-ready-for-kitkat.html So I asked how to create a project to display a list of the "Super Duper SMS," which finally set as default. The whole program must running as a service, without the need any screen for basic functions Receive SMS and should be registered in the core android Thanks for any advice I am tried with this

show a notification on a particular date and time

核能气质少年 提交于 2019-12-01 10:43:17
I need to show a notification on a particular date and time (27-06-2015 13:00). Initially I am showing a toast message. I have created a broadcast receiver to do that. I am calling the pending intent like this - Activity Code - Calendar cal=Calendar.getInstance(); cal.set(Calendar.MONTH,(5)); cal.set(Calendar.YEAR,2015); cal.set(Calendar.DAY_OF_MONTH, 27); cal.set(Calendar.HOUR_OF_DAY,13); cal.set(Calendar.MINUTE,00); Intent myIntent1 = new Intent(this, AlarmBroadCustReciver.class); PendingIntent pendingIntent1 = PendingIntent.getBroadcast(this, 1253, myIntent1, PendingIntent.FLAG_UPDATE

Restrict Broadcast Receiver to application

余生长醉 提交于 2019-12-01 10:35:22
I am working on broadcast receiver and stuck in a problem. I am receiving a broadcast receiver in Manifest file. <receiver class=".MyClass" android:name=".MyClass"> <intent-filter> <action android:name="android.net.conn.CONNECTIVITY_CHANGE" /> <action android:name="android.net.ConnectivityManager.CONNECTIVITY_ACTION" /> <action android:name="android.net.wifi.WIFI_STATE_CHANGED" /> </intent-filter> </receiver> this is working fine and it is calling MyClass whenever there is change in connectivity. Now the problem is whenever my application is not running still this class will receive broadcast

Sending extras to BroadcastReceiver

余生颓废 提交于 2019-12-01 10:35:05
I have an Activity that runs the following code (time and interval are defined): Intent buzzIntent = new Intent(getBaseContext(), BuzzReceiver.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(getBaseContext(), 0, buzzIntent, 0); AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); buzzIntent.putExtra("interval", interval); alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, time, interval * 60 * 1000, pendingIntent); and a BroadcastReceiver that has the following onReceive: @Override public void onReceive(Context context, Intent intent) { try { int