broadcastreceiver

How to play audio file when call starts?

时间秒杀一切 提交于 2019-12-07 03:56:03
问题 I am initiating a voice call from my application. Now i want that when the user on the other side picks up the call, i want to play a recorded audio file. How to go about this? Please help! 回答1: I have found a workaround with this. I play an audio file on device's speakers with full sound when the phone state changes to TelephonyManager.CALL_STATE_OFFHOOK This ensures that the user on the other side can hear the recording. 回答2: In simple and clear words you cant stream any sound on an

Android issue : Debug when phone off

余生长醉 提交于 2019-12-07 03:37:34
问题 To Debug BroadcastReceiver when phone restart, I've tried Some Method but doesn't works and link as follow How to debug BOOT_COMPLETE broadcast receiver's "Force Close" crashes? force-close-crashes 回答1: probably this is not the best way, but i had a similar problem and i used a sleep function of 30 seconds just at the beginning of the boot receiver onReceive method, so i had the time to go to the process list in DDMS perspective and put my app in debug mode, so the breakpoint on the first

Is android.intent.action.DOWNLOAD_COMPLETE an explicit broadcast?

旧巷老猫 提交于 2019-12-07 03:24:03
问题 My app (targetSdk=25) has a broadcast receiver defined in the manifest as follows: <receiver android:name="my.package.DownloadManagerReceiver" android:exported="true"> <intent-filter> <action android:name="android.intent.action.DOWNLOAD_COMPLETE" /> </intent-filter> </receiver> My DownloadManagerReceiver is notified whenever Android's DownloadManager finishes downloading a file, so I can do some processing on the file that was downloaded. I'm working on migrating my app's targetSdk to 27

Android: Detect USB flash drive plugged in

空扰寡人 提交于 2019-12-07 02:59:31
问题 Is there a way to detect when a USB flash drive is plugged into an Android device? I'm able to detect an SD card using a broadcast receiver, but it doesn't work for USB. I'd like to avoid polling. code to register receiver: private void RegisterUpdateReceiver() { IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction("android.intent.action.MEDIA_MOUNTED"); intentFilter.addDataScheme("file"); myReceiver = new MyReceiver(); this.registerReceiver(myReceiver, intentFilter); }

BroadcastReceiver on android.net.conn.CONNECTIVITY_CHANGE called multiple times

眉间皱痕 提交于 2019-12-07 02:20:08
问题 I have the following in my manifest <receiver android:name=".receiver.WifiReceiver" > <intent-filter> <action android:name="android.net.conn.CONNECTIVITY_CHANGE" /> </intent-filter> </receiver> and the following BroadcastReceiver: public class WifiReceiver extends BroadcastReceiver { private static String TAG = makeLogTag(WifiReceiver.class); @Override public void onReceive(Context context, Intent intent) { ConnectivityManager connectivityManager = (ConnectivityManager) context

Send broadcast on notification click

拈花ヽ惹草 提交于 2019-12-07 02:15:28
问题 I have an application which is basically a webview and GCM notifications. I want to achieve the following thing: If the user is in the app and receives a notification, when he clicks the notification I want the webview to load the url provided in the notification. I'm trying to accomplish this by using broadcast receiver but it doesn't work. I dynamically register the receiver in the MainActivity: private void registerNotificationReceiver() { final IntentFilter filter = new IntentFilter();

unregister broadcast receiver registered through manifest

主宰稳场 提交于 2019-12-07 01:50:37
问题 Is it possible to unregister a BroadcastReceiver that has been registered through manifest? Also please let me know if it possible to ignore the BroadcastReceiver , without making any code changes, as this BroadcastReceiver is of no use to me now. Thanks. 回答1: You can disable Receiver with this code: PackageManager pm = getPackageManager(); ComponentName compName = new ComponentName(getApplicationContext(), MyReceiver.class); pm.setComponentEnabledSetting( compName, PackageManager.COMPONENT

Android AlarmManager in a Broadcastreceiver

[亡魂溺海] 提交于 2019-12-06 22:28:24
问题 I have braodcastreceiver, that broadcast receiver shall schedule an alarm. Usually I would do AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); am.set(AlarmManager.RTC, time, myPendingIntent); The problem is that getSystemService is not available in a Broadcast receiver only in an Activty. How would I do it here? Thanks, A. 回答1: AndyAndroid, getSystemService() is part of the Context . You will need to save the Context you receive in your onReceive() method like so... private

moveTaskToBack in onCreate causes activity to show briefly and then hide

怎甘沉沦 提交于 2019-12-06 18:49:26
I have a BroadcastReceiver that receives a push notification, I then start an activity and show a notification. (notice that the activity is not started when the user actions the notification) My intention is to start the activity in "background mode" and then when the user responds to the notification bring the activity to the front. All is working perfectly except that the activity briefly shows and then immediately hides. (flashing activity for a second). Here is my code: BroadcastReceiver... Intent intent = new Intent(context, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW

BroadcastReceiver permission for adb shell

限于喜欢 提交于 2019-12-06 17:43:49
问题 Consider a simple tool using a BroadcastReceiver to achieve a simple goal. Because this should not be used by other applications, it defines a permission with a protectionLevel of signature or signatureOrSystem : <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="any.test"> <permission android:name="any.test.PERMISSION" android:protectionLevel="signatureOrSystem" /> <application android:label="AnyTest"> <receiver android:name=".Receiver" android:exported="true"