android-pendingintent

Android AlarmManager: how to find out the time remaining to trigger the PendingIntent

梦想的初衷 提交于 2019-12-11 02:54:54
问题 I am developing an alarm clock app. Below I have a function to set the alarm. But I want to know how to find the remaining time AlarmManager to trigger the PendingIntent. For example, it is now 10:00 am, and set the AlarmManager to trigger the PendingIntent 23:00, and the calculations we know that the PendingIntent will be called here 13 hours. But how to find out this time remaining? Sorry for my poor english. And I thank you for your attention String schedule = "23:00"; //example Calendar

Store ArrayList<PendingIntent> into SharedPreferences

百般思念 提交于 2019-12-11 02:49:16
问题 II couldn't find an answer for my problem so I decided to post a question. The question is simple. How can I store an ArrayList<PendingIntent> into SharedPreferences ? What is the best way, do i have to use some kind of Serialization ? Thank you in advance, any advice would be great! 回答1: PendingIntent is created with getActivity() , getBroadcast() or getService() . Each of these functions has the same list of parameters: (Context context, int requestCode, Intent intent, @Flags int flags) You

alarmmanager 2 times

眉间皱痕 提交于 2019-12-11 02:39:30
问题 I have a BroadcastReceiver called AlarmReceiver that Toast s "alarm worked". I'm trying to set up a repeating PendingIntent to trigger AlarmReceiver at 5:45 and 17:30, but I see "alarm worked" after few seconds of starting the app. Why is the PendingIntent getting sent immediately? public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Calendar cal1 = Calendar

How to trigger an alarm only once in Android?

▼魔方 西西 提交于 2019-12-11 02:08:29
问题 I set an alarm when the user lands on a certain activity, which is triggered after a certain time. How can I check if this alarm has already been triggered or not, so that it doesn't get set again if the user goes back to this activity ? I can only prevent the alarm getting set again if it's already scheduled but not triggered with this : alarmIntent = PendingIntent.getBroadcast(context, requestCode, intent, PendingIntent.FLAG_NO_CREATE); if (alarmIntent != null) { // Alarm is already set

Why extra data (integer) is not sent in android notification intent?

点点圈 提交于 2019-12-10 23:50:05
问题 The following code to display a notification and send int data, but in the other activity getExtras() returns null . Why? int notificationID = 1; NotificationManager nm = (NotificationManager) getSystemService(getApplicationContext().NOTIFICATION_SERVICE); Intent i = new Intent(getApplicationContext(), DownlodResult.class); i.putExtra("notificationID", 1); PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, i, 0); CharSequence tickerText = "There are updates !"

Confusion regarding number of alarms needed to be set

前提是你 提交于 2019-12-10 23:45:15
问题 I have the following data in SqlLite as well as Postgresql database and am successfully showing it in a tablularlayout on my android widget.It's basically a timetable for college students. a http://www.4shared.com/download/1w7Tyicfce/random3.png I did set OnClickListener for all the textviews individually,which means each and every subject name which you're seeing is clickable in my app. Upon clicking on a subject name i.e a textview ,a page shows up as following. a http://www.4shared.com

FLAG_ACTIVITY_REORDER_TO_FRONT ignored

£可爱£侵袭症+ 提交于 2019-12-10 16:16:49
问题 I have a FragmentActivity with a list of items, and when the app is in background, there can be a push to that item list. when this happens, I want to create a statusbar notification and alert the user on the update. when the user clicks the notification, the activity should reorder to front and show on the screen while showing the new item at the bottom of a list. so I write a notification manager that shows that on the users device: private static void createNotification(String title,

BroadcastReceiver is not called after createChooser(context,intent,IntentSender) is executed

早过忘川 提交于 2019-12-10 14:13:55
问题 I want to detect what app the user selects after I present him with a createChooser() dialog. So I have created my BroadcastReceiver subclass like this: import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.util.Log; public class ShareBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Log.d("INFORMATION", "Received intent after selection: "+intent.getExtras().toString

Pending intent extras are received only when activity is paused

时光总嘲笑我的痴心妄想 提交于 2019-12-10 13:19:19
问题 I'm sending extra string with pending intent from my StateCh.java to MainActivity . My expectation on it is to display dialog in MainActivity when pending intent with extra is arrived (notification is clicked). The problem is when i open the MainActivity and then I click the notification there is no extras inside pending intent and dialog isn't displayed. When I pause the MainActivity (by pressing back button) and click the notification again it works as expected. MainActivity.java: public

unable cancel PendingIntents - Android

大兔子大兔子 提交于 2019-12-10 11:33:50
问题 I have programmed an alarm system that synchronizes with the server where are the information. Sometimes, in the updates on the server some alarms are deleted. Now, it is well removed from the database db4o but I can't cancel pendingIntents already programmed. Now, I've the following code: PendingIntent pendingIntent; public class xxx{ public void updateObjects(){ alarmManager.cancel(pendingIntent);//delete all alarms (...) for(...){ //Update each object ofdb4o with the new object value's. (.