broadcastreceiver

Android IntentService can't instantiate class; no empty constructor

倾然丶 夕夏残阳落幕 提交于 2019-12-22 01:25:00
问题 I have a MainActivity class that needs to access an online API (thus using network resources). This requires a background thread that I've created in a separate file HttpRequestService.java . MainActivity.java: public class MainActivity extends Activity { public static final String API_KEY = "KEYKEYKEYKEYKEY"; public static final String CLIENT_ID = "IDIDIDIDIDIDID"; private final String BROADCAST_ACTION = "com.example.BROADCAST"; private final String EXTENDED_DATA_STATUS = "com.example.STATUS

Permission Denial: broadcasting Intent android.provider.Telephony.SMS_RECEIVED

匆匆过客 提交于 2019-12-22 01:06:15
问题 Hello i am new to Android, I'm getting this problem even after having the required SMS permissions inside my manifest file. I tried a couple of ways but it doesn't work anymore got any idea? AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.phonefinder2" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="8" /> <uses-permission android:name="android.permission

How to Receive SMS Only From One Specific Number (Other SMSs Go to Phone's Inbox)

99封情书 提交于 2019-12-22 01:03:06
问题 My program can successfully send and receive SMS messages. Now I want to receive SMS in my program only from a specific phone number while messages from all other numbers go to the phone's inbox. The code that I use is below. It doesn't work and every SMS message goes to the phone's inbox. I think msg_from in SmsReceiver method, could not get value in for loop and is always null . MainActivity .java public class MainActivity extends Activity { private TextView showSms; private String

Broadcast receiver not working background on some devices

别来无恙 提交于 2019-12-22 00:49:23
问题 I am trying to get WiFi connection changing event using Broadcast Receiver class. I have tested this on Samsung S7 edge and HTC 626Q and it works well (even when the app is closed), but this is not working on Huawei GR5 2017 if the app is closed. It works only when the app is running on screen. Both S7 and GR5 devices have Android 7 (Nougat) OS. Broadcast Receiver public class NetworkChangeReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) {

Get the number I am calling in Android

百般思念 提交于 2019-12-22 00:35:13
问题 I need to get the number that I am calling from my Android device programmatically. What I'm doing now is the following: I listen for android.intent.action.PHONE_STATE being broadcasted which means that either I am being called or am calling (or receiving an SMS etc). In a BroadcastReceiver I retrieve the extra incoming_number from the intent. Sadly I cannot get the number which is being called if I initiate the call though. How can I do this? 回答1: You need to use the Intent android.intent

Android Display own lock instead of default when screen on/off

喜欢而已 提交于 2019-12-22 00:25:15
问题 i want to open my created lock instead of default one,when phone is boot at that time my lock is called. But i want to know when my screen on after locked at that time how i called my lock (my lock activity)Means i want to display my lock instead of default at time of screen on or phone restart or switch on all time. like in our phone lock called all time same as i want to call my lock all time( done with boot ).so please any one help me how i call my lock when screen on/off.please help

How to get contact name when receiving SMS

冷暖自知 提交于 2019-12-21 20:25:27
问题 I have the following code to receive an SMS and I am trying to get the contact name. package com.example.smsTest; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.provider.ContactsContract; import android.provider.ContactsContract.PhoneLookup; import android.telephony.SmsMessage; import android.widget.Toast; public class SmsReceiver extends

Android BLE multiple connections

十年热恋 提交于 2019-12-21 20:23:26
问题 I am trying to create an application that connects and receives notifications from multiple bluetooth low energy devices. I am wondering how this can be achieved. Do I need a separate thread for each connection? How can I make sure the services get discovered and notifications get set in an order that works given the asynchronous nature of the API. I am currently using the same structure provided here: https://developer.android.com/guide/topics/connectivity/bluetooth-le.html. This is setup

How to add Snackbars in a BroadcastReceiver?

ぃ、小莉子 提交于 2019-12-21 20:01:11
问题 Snackbars provide lightweight feedback about an operation by showing a brief message at the bottom of the screen. Snackbars can contain an action. Android also provides a toast, primarily used for system messaging. Toasts are similar to snackbars but do not contain actions and cannot be swiped off screen. My question import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.widget.Toast; public class TestReceiver extends

How to Know which Sms is sent/delivered from Android BroadcastReceiver?

流过昼夜 提交于 2019-12-21 19:52:49
问题 Hi Guys I have made simple app to send multiple SMS on android, and I cannot find known which sms is Sent/Delivered, because the delivery notification does not tell for which it is. here is my code : this.destination = data[0]; this.body = data[1]; PendingIntent piSend = PendingIntent.getBroadcast(aCtx, 0, new Intent(Cons.SMS_SENT),0); PendingIntent piDelivered = PendingIntent.getBroadcast(aCtx, 0, new Intent(Cons.SMS_DELIVERED), 0); SmsManager smsManager = SmsManager.getDefault(); smsManager