android-activity

How do I avoid onCreate() being called when starting an Activity?

橙三吉。 提交于 2020-01-11 05:48:05
问题 I want to reload an activity from stack. I use startActivity() to start new activities. When I'm on Activity D I want to reload Activity A and not start a new Intent. I can't use startActivity() when calling A from D because it will fire onCreate() which starts a thread to fetch some data. EDIT : Updated the stack. If I use FLAG_ACTIVITY_REORDER_TO_FRONT it calls the onCreate() method again. Following is my scenario. Login Activity ̣→ Activity A → Activity B → Activity C → Activity D →

Java Keyboard/Mouse activity (even outside of my app)

隐身守侯 提交于 2020-01-11 05:23:07
问题 I need to detect when the mouse or keyboard activity is present. My application runs in the background (tray) and I need to detect this activity even when my app isn't in focus. I don't need to know what keys were pressed, but simply WHEN they are pressed. Can I do this with just Java? I have read some solutions using JNI and C++/C but they seem to be OS specific. Is there an easy solution to this that will work with Windows, Linux, and Mac? Thanks! 回答1: Since JNI is required, which relys on

Go back to specific activity from stack

我怕爱的太早我们不能终老 提交于 2020-01-11 04:32:11
问题 I'm trying to do something like file manager. And in action bar I wanna to do folder navigation like in "google drive" app. I need create method which can go to previous activity by number from end, or something like this. Example: So if I have stack: [1] -> [2] -> [3] -> [4] -> [5] And I need go to second: so I need delete [3], [4], and [5] from stack and go to [2]. All activities is one class ContentActivity.java. How it possible to do? UPDATE: Some code how I start activities: public class

SQLite onUpgrade()

别等时光非礼了梦想. 提交于 2020-01-10 15:53:07
问题 i have a problem in the SQLite database in android. In my onCreate(SQLiteDatabase db) method of SQLiteOpenHelper class, i am creating tables. Now i have this application uploaded at the playstore. Now i figured that i need one more coloumn in those tables. If i put an update of the application in the playstore (with new queries in onCreate() method), next time the OnUpgrade() method will be called and hence table wont be created again. so please tell me is there any way to delete the SQLite

How to reference child activity from TabHost to call a public function?

做~自己de王妃 提交于 2020-01-10 07:18:46
问题 I have a TabHost with two child activities in it (in two tabs). I also implemented a public function in one of these activities that i would like to call from my parent (TabHost), to trigger some action within the tab. Is it possible to reference the activity itself from the TabHost to call a public function? Thanks here is my tabhost setup: res = getResources(); tabHost = getTabHost(); TabHost.TabSpec spec; Intent intent; intent = new Intent().setClass(this, home.class); spec = tabHost

How to reference child activity from TabHost to call a public function?

烂漫一生 提交于 2020-01-10 07:18:05
问题 I have a TabHost with two child activities in it (in two tabs). I also implemented a public function in one of these activities that i would like to call from my parent (TabHost), to trigger some action within the tab. Is it possible to reference the activity itself from the TabHost to call a public function? Thanks here is my tabhost setup: res = getResources(); tabHost = getTabHost(); TabHost.TabSpec spec; Intent intent; intent = new Intent().setClass(this, home.class); spec = tabHost

How can I show my activity as a dialog in Android?

谁说胖子不能爱 提交于 2020-01-10 02:49:25
问题 I am working on my first Android application, and am trying to style my activity. Ultimately, I would like for my activity to look the same as a dialog. I have given all my activities the Theme.Dialog style using the following code in my AndroidManifest.xml : <application android:icon="@drawable/group" android:label="@string/app_name" android:theme="@android:style/Theme.Dialog"> </application> This gives my activities the "floating" appearance and the borders of a dialog, but not the styled

Android: how to make an activity return results to the activity which calls it?

谁都会走 提交于 2020-01-08 17:14:13
问题 I have a Location activity that can be called from many activities, such as Sign up and Order . In the Location activity the user enters his location, so the activity Location will return this new location to that activity which called it. So when the Sign up activity calls the Location activity, it has to return the data to the Sign up activity. Another time the Order activity will do the same thing. Note I know you will tell me that I should post the code, but I am not asking you to give me

Android image button open new activity

可紊 提交于 2020-01-07 08:26:08
问题 I would like to open new activity from an image button in android. I tried with this code, but doesn't work. main.class import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.content.Context; import android.view.View; import android.widget.ImageButton; public class main extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); openMenu(); } public void

How do I start another activity when a button defined in main.xml is clicked

爷,独闯天下 提交于 2020-01-07 06:23:06
问题 I have two classes. One is Main and the other is HelloWorld. When I click a button which is defined in main.xml I want it to display a message defined in HelloWorld class to start. When i click the button it does not do anything.Code is given below. If anything else is required to put up let me know. Thanks Main.java public class Main extends MapActivity implements LocationListener { /** Called when the activity is first created. */ MapView map; long start; long stop; int x, y; GeoPoint