broadcastreceiver

Chang Phone to Silent Mode on BroadCast Recieving in Xamarin Android

女生的网名这么多〃 提交于 2019-12-24 18:41:03
问题 MainActivity.cs private void StartAlarm() { Intent myIntent; PendingIntent pendingIntent; myIntent = new Intent(this, typeof(AlarmToastReceiver)); pendingIntent = PendingIntent.GetBroadcast(this, 0, myIntent, 0); alarm_manager.Set(AlarmType.RtcWakeup, calndr.TimeInMillis, pendingIntent); } AlarmToastReceiver.cs [BroadcastReceiver(Enabled =true)] public class AlarmToastReceiver : BroadcastReceiver { public override void OnReceive(Context context, Intent intent) { Toast.MakeText(context,

BroadcastReceiver in order to pass data from another Activity to Fragment

喜欢而已 提交于 2019-12-24 17:21:56
问题 Let's say I have MainActivity where are few Fragments in ViewPager. I want to pass data from another Activity to one of these fragments. I'm doing this by BroadcastReceiver. public class MyFragment extends Fragment { private MyFragmentReceiver mReceiver; public MyFragment() { super(); } @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); mReceiver = new MyFragmentReceiver(); getActivity().registerReceiver(mReceiver, new IntentFilter(

Android referral removed in analytics v3?

风格不统一 提交于 2019-12-24 13:06:13
问题 I've spent the last two days trying to find a workaround for this. I need to pre-config my app depending on the referral and since google play is broadcasting an Install Referrer intent when an app is installed, I created my own receiver for this task. The code for the manifest declaration and the Receiver is: Manifest declaration: <receiver android:name="my.package.CustomReceiver" android:exported="true" > <intent-filter> <action android:name="com.android.vending.INSTALL_REFERRER" /> <

how to get running application/package name using broadcast receiver

十年热恋 提交于 2019-12-24 13:00:26
问题 in my application i want to write code of receiving broadcast for which application is running.like when we run/open any application my broadcast receiver should receive it. how can i get the app name/ package name??? public class Receiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if("android.intent.action.PACKAGE_FIRST_LAUNCH".equals(intent.getAction())) System.out.println("context..."+context.getPackageName()); } } androidmanifest file-

How to get the caller's number?

落花浮王杯 提交于 2019-12-24 12:53:03
问题 I am creating one application,what I am trying is whenever user cut or disconnect call,one alert dialog should appear with caller's number,I followed this tutorial public class MyCallReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { // TODO Auto-generated method stub if (intent.getStringExtra(TelephonyManager.EXTRA_STATE).equals(TelephonyManager.EXTRA_STATE_RINGING)) { // get the phone number String incomingNumber = intent.getStringExtra

BroadcastReceiver to send notification and update ui if activity, active

巧了我就是萌 提交于 2019-12-24 12:44:09
问题 I have an activity which just displays a daily counter. When the day ends, i want to send a notification with last day counter, insert it in a db and if the app is running update the counters label to zero. I think i must register a static <receiver>android.intent.action.DATE_CHANGED</receiver> . so as to get notified even if the activity is not running. There I insert the value in DB and i send the notification. And a dynamic created broadcast receiver which i will unregister onPause, which

Handling Home button android for developing lock screen

大憨熊 提交于 2019-12-24 12:29:40
问题 I am developing lock screen application for that i need to disable the home button. some one told to me kept in the manifest as category as default, home but when ever device boot completed my activity launches but not finishing.because I my application is home How to handle the Home button.How Go locker application handled Home button <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> <category android:name=

Broadcast receiver not unregistering

独自空忆成欢 提交于 2019-12-24 12:23:45
问题 I want to give the user the ability to unregister/register the broadcast receiver with the click of the button. When the button is pressed for the first time, the broadcast receiver is registered and a toast comes up when the device is connected. My problem is when I press the button again, the broadcast reciever is not unregistering like I specified. Can somebody please check if there is something wrong with mylogic, or explain to me if there is another approach to detecting when usb is

Prevent onDestroy when Bluetooth connection state changes

百般思念 提交于 2019-12-24 11:46:03
问题 Goal If an already connected bluetooth device disconnects, and an Activity is already running, close the Activity Problem When the bluetooth device connection state changes through BluetoothAdapterProperties: CONNECTION_STATE_CHANGE , it seems like a new Activity is created or the current one restarts. There is nothing in the code that listens and/or should react to bluetooth connection state changes. The problem manifests itself in the use of BroadcastReceivers which in turn starts the

How to load activity from BroadcastReceiver onReceive

故事扮演 提交于 2019-12-24 11:41:53
问题 I want to load an activity from the BroadcastReceiver onReceive method. I have 2 activities, one is the main and the second I created. I want to load the second activity from onReceive but it's loading the main activity and I don't know why.. This is the intent on onReceive() : Intent i = new Intent(context, BTNotifierWarning.class); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(i); this is the BTNotifierWarning class: package com.btnotifier; import android.app.Activity;