android-activity

how can I send a List into another activity in Android Studio

早过忘川 提交于 2020-01-14 06:57:09
问题 I know that I can add a string or an integer by putting putextra() on my Intent but what do I do if I have to send a List? For example, My main activity contains a list, I have a different activity that adds an item into the list and I have a third activity that needs to show the whole list 回答1: Your object can also implement Parcelable interface. Then you can use Bundle.putParcelable() method and pass your object between activities within intent. Photostream application uses this approach

How to switch between activities

心不动则不痛 提交于 2020-01-14 04:17:08
问题 In my app I have three activity as Activity 1 Activity 2 Activity 3 How to switch between activities. So how can this be done? public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.settingOpt: Intent intent = new Intent(this, SettingsForm.class); this.startActivity(intent); this.finish(); break; case R.id.reminderOpt: Intent intentR = new Intent(this, ReminderForm.class); this.startActivity(intentR); break; case R.id.helpOpt: Intent intentH = new Intent

Closing an android application ?

房东的猫 提交于 2020-01-14 04:12:48
问题 Hi i want to know how to close an application in Android. Actually i am having idea by using the finish() method we can close present activity.. But what i want is, the following code defines remaining... Main.java Handler handle=new Handler(); handle.postDelayed(new Runnable() { @Override public void run() { // TODO Auto-generated method stub startActivity(new Intent(ZzzzzProjActivity.this,Second.class)); } }, 3000); Second.java /*** same above code***/ Third.java @Override public boolean

When do I need a base activity and base fragment?

空扰寡人 提交于 2020-01-13 19:48:03
问题 In lot of examples I see, all the activities and fragments extends from base activity and base fragments. 2 questions: When should I use it? What kind of code should go in it? 回答1: Usually I use a base Activity/Fragment when I need to do some work in some of life-cycle callbacks of all of my Activitys/Fragments. For example if you use Butter Knife (very recommended), you need to call Butterknife.bind(Activity a) after calling setContentView . So it's better if you create a base activity and

How to Start an Intent from a contained class of an Activity

試著忘記壹切 提交于 2020-01-13 19:36:11
问题 I'm looking for the best way to start an intent from a class that is not an Activity, but is a contained object of an Activity class. For example the Activity Class: Class MainActivity extends ListActivty { ... TestLauncher tester; } and the class that I want to start the intent from: Class TestLauncher { public TestLauncher () { //Code to create an intent needs a Context //Intent i = new Intent(Context, class) //Code to start activity needs to be called with an Activity //Activity

Life cycle of view android

孤街浪徒 提交于 2020-01-13 16:45:48
问题 I want some view animation to occur after resuming my activity, but I can't succeed to catch the time after all the views loaded and the animation started before all the views loaded (before the animation transition). i tried to use onDraw, onWindowFocusChange, onResume, I discovered that onDraw is the last method on the life cycle of view but I still saw that the animation start before the user see the all the views 回答1: Here is Android Activity lifecycle & Android View lifecycle tested on

Life cycle of view android

痞子三分冷 提交于 2020-01-13 16:44:48
问题 I want some view animation to occur after resuming my activity, but I can't succeed to catch the time after all the views loaded and the animation started before all the views loaded (before the animation transition). i tried to use onDraw, onWindowFocusChange, onResume, I discovered that onDraw is the last method on the life cycle of view but I still saw that the animation start before the user see the all the views 回答1: Here is Android Activity lifecycle & Android View lifecycle tested on

finish activity from non activity

痞子三分冷 提交于 2020-01-13 10:01:14
问题 I am developing an app. I want to call a alert dialog from 1st activity. The alert dialog is written in another class which is a non activity class. The need of application is that the calling activity should finish from alert which is written in non activity class. The code of calling the alert is as below. Calling the alert from 1st activity: public class Activity1 extends Activity { /** Called when the activity is first created. */ @Override protected void onCreate(Bundle

How to detect user activity with a Java service running on Windows?

故事扮演 提交于 2020-01-13 09:18:06
问题 My goal is to create a system monitoring application using Java. I would like to know when a user is doing activity on a Windows PC. The result would be something like this: 8:00 - 8:15 activity 9:12 - 10:29 activity 12:24 - 15:34 activity I'm not interested in any other information (which key was pressed, application used, etc.). Only user activity. Is this even possible in Java? I plan to run my java application as a service. But as for getting events when a user uses the computer, I have

Android Datepicker - How to pass date from activity to fragment

拥有回忆 提交于 2020-01-13 05:41:28
问题 All documentation & example seems to be related to "How to get the date selected from the datepicker dialog back in the activity". And almost all of them sets the current date as default date in the datepicker dialog. However how do I pass a specific date so that when the datepicker opens, it shows that date & not current date? The problem I'm facing is, when the user clicks a button and the datepicker diaglog opens for the first time, it shows the current time. The user changes the value and