|
Quote: the system stops the service frequently(maybe every 30 minutes) and then restarts it, passing a null intent to the onStartCommand() method Instead of returning START_STICKY from onStartCommand try returning START_REDELIVER_INTENT . This will ensure that the system redelivers the initial Intent that was passed to the service when the service was started.
|
|
|
|
|
Thanks for the response. The null intent is not the problem. The code saves the data from the original intent and uses the startId value to recognize that is has been restarted.
The problem is that my service is NOT being restarted promptly or some times not at all.
|
|
|
|
|
As you have mentioned that it is being killed frequently, it seems that the device is running low on resources and in such a case the system will not restart the Service until adequate resources are available.
Try running the service in Foreground and see if it helps.
However, if your device is running Android 4.4.2 then it's a known issue - https://code.google.com/p/android/issues/detail?id=63793[^]
|
|
|
|
|
Thanks again. The link has some good ideas. My tablet is running version 4.3
I do use startForeground() method and it shows a Notification.
The frequency of being stopped was almost exactly every 30 minutes.
The times of some of the restarts are 5 seconds after an Alarm is supposed to go off and send an Intent to my service.
modified 16-Oct-14 14:55pm.
|
|
|
|
|
hi i want to develop an mobile application using android and i don't know where to start can anyone please help by sending me simple code to practise
|
|
|
|
|
|
Member 11116727 wrote: ...and i don't know where to start... Try here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
|
Are you intending to use Java (and write a native app) or use a cross-platform tool such as Xamarin?
If you are opting for the latter then read my introductory article Introduction to Xamarin.Android[^]
|
|
|
|
|
this is my dialog
@Override
protected Dialog onCreateDialog(int id, Bundle args){
switch(id){
case 1:
return new AlertDialog.Builder(this)
.setIcon(R.drawable.ic_launcher)
.setTitle("Pick some")
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int whichButton)
{
}
})
.setNegativeButton("cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int whichButton)
{
}
})
.setMultiChoiceItems(items, itemsChecked, new DialogInterface.OnMultiChoiceClickListener() {
public void onClick(DialogInterface dialog, int which,boolean isChecked) {
}
}
)
.create();
How can I detect when the dialog is load ?
i need to do something when the dialog is up and see it on the screen
* this is a multi-checkbox dialog, and i need to uncheck all.
thanks
modified 4-Oct-14 6:24am.
|
|
|
|
|
|
I just wrote what I tried. May have been wrong and that is not the way, that's why I turned to for help
|
|
|
|
|
OK, but you have an error message telling you what you have done wrong. You need to fix that before you can proceed.
|
|
|
|
|
I tried a few things but still not working
I have been really desperate, do not know how to solve it
|
|
|
|
|
Have you corrected the coding error that I pointed out to you? Or do you have some new problem?
|
|
|
|
|
no errors, i update my question.
|
|
|
|
|
|
goldsoft wrote: How can I detect when the dialog is load ? i need to do something when the dialog is up and see it on the screen Without more information as to your need/intent, this goes against Android's asynchronous (i.e., non-blocking) interface.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
thanks for the help,
what i need to do is uncheck all my multi checkBoxs
that i have in the dialog.
when i press the button and the dialog came up -
i need to uncheck all my checkBoxs
|
|
|
|
|
Hai there,
I have drawn a circle using canvas bitmap by taking linear layout, Now I want to swipe that circle so as to draw another circle in the same xml file and display.Kindly help!
|
|
|
|
|
Hi there,
I have extracted the json data, but now I need to set those values in options menu as menuitems. Please kindly help!
SubMenu submenu = menu.addSubMenu("Select");
submenu.add(a1);
submenu.add(a2);
submenu.add(a3);
submenu.add(a4);
submenu.add(a5);
The above code I used to add the values in options menu with onOptionsCreateMenu method. a1,a2,a3,a4,a5 are not strings those are extracted and stored in string so just I m added them but failed..!
|
|
|
|
|
Member 11108789 wrote: I m added them but failed You need to explain what "failed" means. Show the actual code, the values of your variables and any error messages, or a proper description of what happens.
|
|
|
|
|
The code for how I extracted from json:
if((jsonarray.get(0).toString()) != null){
JSONObject jsonobj = new JSONObject(jsonarray.get(0).toString());
Log.e("aptlist", jsonobj.toString());
JSONArray array1= jsonobj.getJSONArray(TAG_APTLIST);
String a1= array1.get(0).toString();
String a2= array1.get(1).toString();
String a3= array1.get(2).toString();
String a4= array1.get(3).toString();
String a5= array1.get(4).toString();
}
Now I want those a1,a2,a3,a4,a5 values in optionsmenu when I click.
I tried as below,but got error as NullPointException
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
getMenuInflater().inflate(R.menu.main, menu);
SubMenu submenu = menu.addSubMenu("Select Apartment");
submenu.add(a1);
Log.e("msg from a1", a1.toString());
submenu.add(a2);
submenu.add(a3);
submenu.add(a4);
submenu.add(a5);
return true;
}
|
|
|
|
|
Member 11108789 wrote: but got error as NullPointException That just means you are trying to use a pointer that has not been initialised, but we cannot guess where it occurs. Use your debugger to trace through the code to identify which line is the problem.
|
|
|
|
|
Hey! how can we extract JSON object if it has a multiple values See below for an example
{"aptName":["AG01","AG02","AG03","AF01","AF02",],},
If it is {"aptName1:"11.765","aptName2:"16.327",} I m able to extract. But I need help for the above one.
and here is my URL: http://nuclious.com/monitoring/QuickAppDataQuery2.php?mobileNo=8123168934..Please check this and let me know how to extract the values. Note:I know how to extract if there is single value.
sunil
|
|
|
|