broadcastreceiver

How can I Access Database in BroadcastReceiver Class in Android?

断了今生、忘了曾经 提交于 2021-02-08 05:28:30
问题 I have a BroadcastReceiver class to receive incoming call. I want to compare the incoming number with a numbers from my database. Now I can't understand how to use database in BroadcastReceiver class. I make object of DBAdapter class in onReceive() method in this way: @Override public void onReceive(Context context, Intent intent) { DBAdapter db = new DBAdapter(contenxt); Cursor c = d.getAllData(); while(c.moveToFirst){ do{ Log.v("Data : "+c.getString(2)); } while(c.moveToNext); } } Above

Trying to start an activity from broadcast receiver

浪尽此生 提交于 2021-02-08 03:43:20
问题 I'm trying to create a lockscreen. When I try to start the com.fira.locker.LockScreenActivity from the broadcastReceiver, I just get an error. The error says: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Intent android.content.Intent.setFlags(int)' on a null object reference This is my code: package com.fira.locker; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.os.Environment; import

How to get MMS id Android Application

妖精的绣舞 提交于 2021-02-07 15:40:42
问题 can anyone help me out to find MMS id, i using this code to get MMS text but i don't know the MMS id (mmsId) so i stopped !! I'll be thankful for your help Samila 回答1: Uri mmsInboxUri = Uri.parse("content://mms"); Cursor mmsInboxCursor = getContentResolver().query(mmsInboxUri ,new String[] {"_id","msg_box","ct_t","date"}, "msg_box=1 or msg_box=2", null, null); int count = mmsInboxCursor.getCount(); if(mmsInboxCursor != null){ try{ if (mmsInboxCursor.moveToFirst()) { do{ System.out.println("<=

How to get MMS id Android Application

老子叫甜甜 提交于 2021-02-07 15:40:10
问题 can anyone help me out to find MMS id, i using this code to get MMS text but i don't know the MMS id (mmsId) so i stopped !! I'll be thankful for your help Samila 回答1: Uri mmsInboxUri = Uri.parse("content://mms"); Cursor mmsInboxCursor = getContentResolver().query(mmsInboxUri ,new String[] {"_id","msg_box","ct_t","date"}, "msg_box=1 or msg_box=2", null, null); int count = mmsInboxCursor.getCount(); if(mmsInboxCursor != null){ try{ if (mmsInboxCursor.moveToFirst()) { do{ System.out.println("<=

How to get MMS id Android Application

和自甴很熟 提交于 2021-02-07 15:40:09
问题 can anyone help me out to find MMS id, i using this code to get MMS text but i don't know the MMS id (mmsId) so i stopped !! I'll be thankful for your help Samila 回答1: Uri mmsInboxUri = Uri.parse("content://mms"); Cursor mmsInboxCursor = getContentResolver().query(mmsInboxUri ,new String[] {"_id","msg_box","ct_t","date"}, "msg_box=1 or msg_box=2", null, null); int count = mmsInboxCursor.getCount(); if(mmsInboxCursor != null){ try{ if (mmsInboxCursor.moveToFirst()) { do{ System.out.println("<=

MVVM - Accessing ViewModel/SQLite in a BroadcastReceiver started from a notification when app is closed

。_饼干妹妹 提交于 2021-02-07 14:15:36
问题 I have a reminder notification that is sent every few days. The sending of that notification is triggered with a repeating AlarmManager . The notification itself is built in the onReceive of my BroadcastReceiver (as described here). So when onReceive is triggered, the app is not even open/running. Now at that point I want to access my (local) SQLite database and get the correct content to build the notification with, but how would I get a ViewModelProvider (xxx in the code) in this place to

MVVM - Accessing ViewModel/SQLite in a BroadcastReceiver started from a notification when app is closed

╄→尐↘猪︶ㄣ 提交于 2021-02-07 14:13:15
问题 I have a reminder notification that is sent every few days. The sending of that notification is triggered with a repeating AlarmManager . The notification itself is built in the onReceive of my BroadcastReceiver (as described here). So when onReceive is triggered, the app is not even open/running. Now at that point I want to access my (local) SQLite database and get the correct content to build the notification with, but how would I get a ViewModelProvider (xxx in the code) in this place to

MVVM - Accessing ViewModel/SQLite in a BroadcastReceiver started from a notification when app is closed

↘锁芯ラ 提交于 2021-02-07 14:12:40
问题 I have a reminder notification that is sent every few days. The sending of that notification is triggered with a repeating AlarmManager . The notification itself is built in the onReceive of my BroadcastReceiver (as described here). So when onReceive is triggered, the app is not even open/running. Now at that point I want to access my (local) SQLite database and get the correct content to build the notification with, but how would I get a ViewModelProvider (xxx in the code) in this place to

BroadcastReceiver fires multiple times (PROVIDERS_CHANGED_ACTION)

女生的网名这么多〃 提交于 2021-02-07 12:55:42
问题 Why BroadcastReceiver was trigger multiple time. My Sample Project is like below code ANDROID MANIFEST <receiver android:name=".LocationProvideListener" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="android.location.PROVIDERS_CHANGED"/> </intent-filter> </receiver> BBROADCAST RECEIVER public class LocationProvideListener extends BroadcastReceiver { private static final String TAG = "LocationProvideListener"; @Override public void onReceive(Context

BroadcastReceiver fires multiple times (PROVIDERS_CHANGED_ACTION)

断了今生、忘了曾经 提交于 2021-02-07 12:53:58
问题 Why BroadcastReceiver was trigger multiple time. My Sample Project is like below code ANDROID MANIFEST <receiver android:name=".LocationProvideListener" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="android.location.PROVIDERS_CHANGED"/> </intent-filter> </receiver> BBROADCAST RECEIVER public class LocationProvideListener extends BroadcastReceiver { private static final String TAG = "LocationProvideListener"; @Override public void onReceive(Context