android-1.5-cupcake

How to programmatically enable GPS in Android Cupcake

99封情书 提交于 2020-01-26 09:17:29
问题 I'm currently writing an app in Android that works with the GPS. At the moment I'm able to work out whether the GPS is enabled. My problem is that I want to enable the GPS on app startup if it is disabled. How can I do this programmaticaly? 回答1: You can't, starting with Android 1.5. The most you can do is pop open the activity to allow the user to toggle it on/off. Use the action held in android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS to craft an Intent to open this activity. 回答2:

How to programmatically enable GPS in Android Cupcake

最后都变了- 提交于 2020-01-26 09:17:06
问题 I'm currently writing an app in Android that works with the GPS. At the moment I'm able to work out whether the GPS is enabled. My problem is that I want to enable the GPS on app startup if it is disabled. How can I do this programmaticaly? 回答1: You can't, starting with Android 1.5. The most you can do is pop open the activity to allow the user to toggle it on/off. Use the action held in android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS to craft an Intent to open this activity. 回答2:

AlertDialog MultiChoiceItems Listener problems

孤街醉人 提交于 2019-12-21 12:35:18
问题 I am currently using the AlertDialog.builder to create a multichoice list for the user (checkboxes). This works great, except we want one of the buttons to deselect all of the others in the list. builder.setMultiChoiceItems(list, checked, new DialogInterface.OnMultiChoiceClickListener() { public void onClick(DialogInterface dialog, int item, boolean isChecked) { if(item == ANY_ITEM_BUT_0) { ((AlertDialog) dialog).getListView().setItemChecked(0, false); } } }); When using "true" it will

Using a wakelock in a service Android 1.5

淺唱寂寞╮ 提交于 2019-12-21 01:18:23
问题 Hello I am trying to use a service to control a wakelock so I can permanently leave the screen on when my application is running. I create the wakelock and activate it in onCreate() and release it in onDestroy() however I get the error "wl cannot be resolved". Can someone explain how I can get over this? Code below: public class WakeLockService extends Service { @Override public IBinder onBind(Intent arg0) { // TODO Auto-generated method stub return null; } @Override public void onCreate() {

Killing android application on pause

醉酒当歌 提交于 2019-12-17 19:16:17
问题 I have an application which I would like to be fully disabled/closed when it is paused (IE. When the user presses the Home, End (call) and Back button I would like the application to be closed, instead of being saved in the history stack). How do I do this....? Thanks. 回答1: Implement onPause() in your activity and call finish() on your activity. Bear in mind, though, that this will occur on every pause, including dialogs, incoming calls, users activating a Notification . You might want to

How to time-bomb an Android application?

独自空忆成欢 提交于 2019-12-09 04:29:14
问题 Hello does anyone have a code example of how I can time bomb an Android application so It will not work after a given date? I would like to release a "beta" application for testing but would like to make sure it will only work while the application is officially in beta. 回答1: I would suggest using the Calendar class and having your application checking the current date against your expiration date in your OnResume(s). The code would look something like this: protected void onResume() { super

Does anyone know whether the Android addProximityAlert on the LocationManager is battery intensive

*爱你&永不变心* 提交于 2019-12-04 14:10:09
问题 I just basically want to add about 20 and sometimes 80 Proximity Alerts with no time expiration with a radius of around 500 meters. Just wondering whether by doing this will suck up the battery real quick? also would it make any difference by reducing the radius? 回答1: This will definitely eat your battery real quick. You never want to be setting more than a couple of proximity alerts in any case, the use-case you describe isn't really catered for in Proximity Alerts. Proximity Alerts should

AlertDialog MultiChoiceItems Listener problems

☆樱花仙子☆ 提交于 2019-12-04 04:08:20
I am currently using the AlertDialog.builder to create a multichoice list for the user (checkboxes). This works great, except we want one of the buttons to deselect all of the others in the list. builder.setMultiChoiceItems(list, checked, new DialogInterface.OnMultiChoiceClickListener() { public void onClick(DialogInterface dialog, int item, boolean isChecked) { if(item == ANY_ITEM_BUT_0) { ((AlertDialog) dialog).getListView().setItemChecked(0, false); } } }); When using "true" it will successfully check the box, but when using false it does not uncheck it (unless i have manually set it to

Does anyone know whether the Android addProximityAlert on the LocationManager is battery intensive

笑着哭i 提交于 2019-12-03 09:39:24
I just basically want to add about 20 and sometimes 80 Proximity Alerts with no time expiration with a radius of around 500 meters. Just wondering whether by doing this will suck up the battery real quick? also would it make any difference by reducing the radius? This will definitely eat your battery real quick. You never want to be setting more than a couple of proximity alerts in any case, the use-case you describe isn't really catered for in Proximity Alerts. Proximity Alerts should switch between GPS and Network as required, but in my experience they tend to stick to GPS whenever it's

Android animated GIF (Cupcake)

大憨熊 提交于 2019-11-30 15:45:54
问题 I've used animated GIFs in Android pre cupcake however my old code no longer works. To be exact: Movie.decodeStream Always returns null... Does anyone have any workarounds/fixes to play animated GIFs? 回答1: There's a bug report for this. Looks like the only option currently is to split it up and do frame-by-frame animation manually. There's instructions in the docs for how to do this. 来源: https://stackoverflow.com/questions/1383246/android-animated-gif-cupcake