broadcastreceiver

Monitor Currently Running Application

守給你的承諾、 提交于 2019-12-02 10:24:37
I am encountering a problem that i can't not solve for the moment. The purpose of the code is to monitor which applications are running at current moment. I used the following code and logged the resulting package name, it worked. ActivityManager am = (ActivityManager) context.getSystemService(Activity.ACTIVITY_SERVICE); String packageName = am.getRunningTasks(1).get(0).topActivity.getPackageName(); Log.i("TTWYMonitor", packageName); But I use that code in a BroadcastReceiver , nothing happened. In manifest ,I declared an intent receiver android:name=".MonitorApplication. What should I do,

android register a permanent Broadcast Receiver

一曲冷凌霜 提交于 2019-12-02 10:19:19
问题 I need to create a BroadcastReceiver which performs certain task immediately each time the device boots up. Also, when a certain button is clicked, the receiver should stop starting on boot. Can someone help me to manage that? 回答1: All you need to solve the first part of your question is to make a BroadcastReceiver for it and declare it in your Manifest as: <receiver android:name=".MyBootReceiver" android:enabled="true" > <intent-filter> <action android:name="android.intent.action.BOOT

Programatically send SMS Android (Not receiving status)

。_饼干妹妹 提交于 2019-12-02 10:16:00
问题 I am using http://mobiforge.com/developing/story/sms-messaging-android code example word for word except for the fact that I changed: import android.telephony.gsm.SmsManager; to: import android.telephony.SmsManager; The SMS is sending fine however I am not getting the TOAST message that it was delivered (sent to the network). I am trying to integrate SMS into my application and this is important. I am sure this can be done because how else would the stock SMS app know when to stop displaying

Why BroadcastReceiver is not running in the background?

我怕爱的太早我们不能终老 提交于 2019-12-02 10:00:06
In one application (App1) I am broadcasting a message. This code below is correct -> the broadcast is detected if I try to get Broadcast in the same project. sendBroadcast(new Intent("com.example.MESSAGE_INTENT").putExtra("MESSAGE", ((EditText) findViewById(R.id.textField)).getText())); I created App2 which has a BroadcastReceiver which waits for the broadcasted Intent but the method onReceive is never invoked. How to change the BroadcastReceiver app to make the service work in background all the time? App2 manifest and code: package com.example; import android.content.BroadcastReceiver;

Android Wifi broadcast receiver not working as expected

痴心易碎 提交于 2019-12-02 09:57:31
I have to get the WiFi ssid whenever phone connects to new WiFi network. I registered the following receiver `registerReceiver(this.mybroadcast, new IntentFilter(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION));` This part of code works perfectly. But in onReceive method, NetworkInfo info = intent.getParcelableExtra(WifiManager.EXTRA_WIFI_INFO)); always returns null. I tried EXTRA_NETWORK_INFO as well, but it also returns Null. I can't use this.registerReceiver(this.mybroadcast, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));, as the service will stop/start after n minutes and

Android dynamic and static BroadcastReceivers

£可爱£侵袭症+ 提交于 2019-12-02 09:52:33
I'm about to insert some reminders on my app. Each of them will have different time. Reading about BroadcastReceiver the static version runs even when an app isn't running. Dynamic version only when app is alive, being destoyed on onPause and recreated on onResume. Because I'm inserting reminders, do I need to create static receivers for each of my reminders or not? Is the right way to handle reminders with different times? Static or Dynamic? We may assume that reminders may be set for some longer periods of time after which it will be triggered. Therefore, it is safer to use static broadcast

Broadcast receiver, check a checkbox preference state on bootup then send a notification

不羁的心 提交于 2019-12-02 09:52:05
My problem is that when I try to read a checkbox preference state from a different activity on bootup then send a status bar notification. Then when the device boots the I get a force close error message popup then when I go into the error log I don't understand what happens. The code for the broadcast receiver is shown below: @Override public void onReceive(Context context, Intent intent) { if(intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)){ //this creates a reference to my preferences activity Prefs prefsC = new Prefs(); SharedPreferences prefs = context.getSharedPreferences("Prefs"

Android: How to get the installed App information using Broadcast receiver

给你一囗甜甜゛ 提交于 2019-12-02 09:43:51
I am new to android. I am using a Broadcast receiver which listens when a app is installed or removed.. When a app is installed or removed my Broadcast Receivers's onReceive(context,intent) will be called.. Now i need to get the info about the application installed or removed (Mainly the package name).. Plz help David Wasser All the information you want is in the Intent extras. Look at How to find the package name which has been uninstalled when using Intent.ACTION_PACKAGE_REMOVED You can try this receiver and permission. (But this seem only work in /system/app)^^" <receiver android:name="com

Download data when internet connectivity is detected

狂风中的少年 提交于 2019-12-02 09:32:41
I want to download some data including json and image(binary data) whenever internet connectivity is available. I have a full working code which can do that. The problem is I have written that code in custom application class. which downloads it and saves locally.But when app is launched the internet connectivity may not be available at that point of time. So what I want to do is send the request and download the data whenever internet connectivity is detected and use that data by saving it in content provider locally. And the app will work even without an internet connection. I am thinking of

password protected uninstall in android 4+ versions [programmatically]

泪湿孤枕 提交于 2019-12-02 07:49:38
i want my app to have a password protected uninstall ... (like app lock) im using folling code it works on Android 2.3 but not on Android 4+ versions MANIFEST FILE <receiver android:name="fyp.invisibleink.UninstallIntentReceiver" > <intent-filter android:priority="0" > <action android:name="android.intent.action.QUERY_PACKAGE_RESTART" /> <data android:scheme="package" /> </intent-filter> </receiver> Uninstalling Activity code ublic class Uninstalling extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout