android-activity

Android : Make this object as Parcelable

天涯浪子 提交于 2020-01-04 06:52:38
问题 I have an object that I need to pass between 2 Activity . The object has HashTable, String[], etc. Can't make out how to make it Parcalebale so that I can populate an array of the object and pass single obj or array to other Activity. My class is : public class TrainRoute { // implements Parcelable private String RouteName; private int RouteIndex; private Context ctx; private Hashtable<String, String> stationsList; private String[] stationsNames; private String[] trainTimings; private boolean

Difference between UI thread and other threads

廉价感情. 提交于 2020-01-04 06:14:20
问题 I have an app that displays a splash screen. The splash screen activity creates a new Runnable which simply sleeps for 1 second and and then launches the main activity: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.splash); UKMPGDataProvider.init(this.getApplicationContext(), Constants.DATABASE_NAME); Thread splashThread = new Thread() { @Override public void run() { try { sleep(ONE_SECOND_IN_MILLIS); } catch

Android: Updating SharedPrefereces on activity resume doesn't work

不问归期 提交于 2020-01-04 05:28:09
问题 I've got an "activity a" which reads some values from SharedPreferences and display them in a TextView , then I call "activity b" where the values from SharedPreferences get updated and written back to SharedPreferences . Finally I go back to "activity a" by pressing the back-button, now the new (updated) values should be read from SharedPreferences and shown in the TextView . But here comes the problem, the values just read from SharedPreferences are still not updated (are not the new ones

Cannot resolve method placeholderfragment error

二次信任 提交于 2020-01-04 04:46:10
问题 I'm really stuck on this error (below): @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_vehiclerecall); if (savedInstanceState == null) { getFragmentManager().beginTransaction() .add(R.id.container, new PlaceholderFragment()).commit(); } } I have the container referenced correctly to XML layout (below): <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res

How to go up to parent Activity that need to be started with extras data?

隐身守侯 提交于 2020-01-04 04:26:25
问题 Suppose I have an app which Activity A will show a post and also its comments. If I click one of the comment, it will go to Activity B . So, Activity B will show comment and also replies for that comment. Up until now, I don't have a problem. I just need to set parent Activity for Activity B to Activity A in manifest.xml . Now, I also have Activity X which will show user profile and also all of their posts and comments. If I click a comment, it will go to Activity B . But, if I click up

How to emulate the process of a background activity is killed by the system because of low memory on Android?

99封情书 提交于 2020-01-04 04:16:25
问题 I'm dealing with the "Low memory: no more background process" problem. My activity is at background and killed when the situation occurs. I'm trying to save and load the instance state to solve it. But since it doesn't happen every time. How should I test my activity with this situation? Thanks! 回答1: You can force your process to die through adb. > adb shell # ps # kill -9 <pid> where <pid> is the process id of your app. Caveat: I don't know if this method of ending the process is the same as

How to pass a parameter from an activity to a service…when the user stop the service

半腔热情 提交于 2020-01-04 04:15:33
问题 I have an activity with a checkbox: if the chekbox is unchecked then stop the service. this is a snippet of my activity code: Intent serviceIntent = new Intent(); serviceIntent.setAction("com.android.savebattery.SaveBatteryService"); if (*unchecked*){ serviceIntent.putExtra("user_stop", true); stopService(serviceIntent); when I stop the service I pass a parameter "user_stop" to say at the service that has been a user to stop it and not the system (for low memory). now I have to read the

Android : Permission Denied Error when changing Launcher Activity

家住魔仙堡 提交于 2020-01-04 02:54:18
问题 I have an android app that I am trying to launch and it gives me the error java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.hoosierag/.MainActivity } from null (pid=32395, uid=2000) not exported from uid 10125 I get this error when I try to change the launcher activity in the manifest. Also I dont get this error when I launch it on the emulator, but when I try to launch it on a device

Android Things: How to exit Android Settings screen?

浪尽此生 提交于 2020-01-04 01:38:51
问题 I succeed to show Android Date Settings by calling : startActivityForResult(new Intent(android.provider.Settings.ACTION_DATE_SETTINGS), 0); but I don't know how to exit, there is no cancel/update button, no back button or navigation bar. Would anyone know how to leave this screen? I use Android Things 0.5.1-devpreview on RPi3 with this example code. 回答1: In order to close Android 's settings app you can either send a back button press event adb shell input keyevent 4 or force close the

Android Things: How to exit Android Settings screen?

六月ゝ 毕业季﹏ 提交于 2020-01-04 01:38:10
问题 I succeed to show Android Date Settings by calling : startActivityForResult(new Intent(android.provider.Settings.ACTION_DATE_SETTINGS), 0); but I don't know how to exit, there is no cancel/update button, no back button or navigation bar. Would anyone know how to leave this screen? I use Android Things 0.5.1-devpreview on RPi3 with this example code. 回答1: In order to close Android 's settings app you can either send a back button press event adb shell input keyevent 4 or force close the