android-activity

Android Resume Activity

十年热恋 提交于 2019-12-08 09:40:15
问题 In my app, I start an activity and then on button click, display an http url (using Intent - VIEW_ACTION) So when in the middle of the activity, if the user clicks the button called "Google", it opens up google.com in the browser. When I hit the back button, it comes back to my original activity screen. How can I get my activity to resume from where it left of? Thanks George 回答1: Take a look of this post: Saving Android Activity state using Save Instance State 来源: https://stackoverflow.com

How to access another activity?

自作多情 提交于 2019-12-08 09:39:23
问题 Just to make it clear, this is not I want. I want to access another Activity's context. Suppose I've two activities, MainActivity and WebActivity . In MainActivity I used oAuth2 login, and after login I start the WebActivity . In WebActivity I need to logout with the function mTencent.logout(MainActivity.this); , the question is how can I access MainActivity from WebActivity ? If I do this directly, I get the error, MainActivity is not an enclosing class? Considering I'm a starter of android,

Android: always launch top activity when clicked on notification

我们两清 提交于 2019-12-08 09:37:30
问题 EDIT : please note: i completely re-explained my question. I have application with two Activites : A and B . Activity A is MAIN . So, application starts, and A appears on the screen. User press the button on it, and new Activity B appears on the screen. So, there's now 2 activities in my "back stack": A and B . Now I press "Home" key, and then click on my app's icon on launcher: Activity B appears on the screen ( not A ), as far as it is top activity in my task. Now question: how can i make

Activity flashes up in portrait before switching to landscape

故事扮演 提交于 2019-12-08 09:34:41
问题 I am creating an android game where every activity is set to be in landscape in the xml manifest file. However, sometimes when going to a new activity it flashes up in portrait for a second before correcting to landscape. Does anyone have any generic reason why this might be? It happens when exiting the level completion screen too early which uses a ScheduledFuture Thanks Andy EDIT (Manifest): <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res

Pass data from one activity to another, BUT go to the other activity later

霸气de小男生 提交于 2019-12-08 09:27:27
问题 My work flow is as follows: LoginActivity -> ActivityB -> ActivityC -> ActivityD I'd like to pass data from LoginActivity to ActivityD, but not go directly to ActivityD. ie, I'd like to pass data from LoginActivity to ActivityD, but go to ActivityB and ActivityC before I get to ActivityD and get the data there. Is this possible? I know to pass data from one activity to another the code is as follows: Intent i = new Intent(getApplicationContext(), AnotherActivity.class); i.putExtra("key", (int

How to launch an activity when lock screen is enabled?

大城市里の小女人 提交于 2019-12-08 09:10:44
问题 How do you launch an activity when the lock screen is enabled? I want to be able to launch an activity as a result of the screen being locked. I already no I can make an activity work on top of the lock screen using WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED but it is a little unclear to me how to start the activity when the screen is locked. Do I need a service to be running that listens for the screen to lock and then launches the activity? 回答1: When the lock screen is enabled, you

how to save data using shared preferences?

廉价感情. 提交于 2019-12-08 09:06:45
问题 i am new developer in android application.i have used shared preference concept to share the data from one activity to another activity.i have implemented code as follows Main.java public class Main extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); TableLayout table=(TableLayout)findViewById(R.id.tableLayout1); table.removeAllViews(); String sName = null; for(int i=0;i<10;i++) { TableRow row=new

why my service starts after ondestroy of activity which was started by this service

送分小仙女□ 提交于 2019-12-08 09:02:16
问题 Today I found the strange problem.In my application I am starting a activity from service Intent in=new Intent(AlarmService.this, GuardActivity.class); in.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(in); Now after sometime i call ondestroy of activity. here I observe that my service is started again. This behavior is very strange.Do any body faced same problem It is simple services with just above line...So I am not posting complete code Activity Timer t = new Timer(); t.schedule

Image zoom activity for android

徘徊边缘 提交于 2019-12-08 08:32:54
问题 I'm trying to implement the double tap and the pinch to zoom activity. I wrote some code for the first one but it seem not to work (i can use only the android emulator for eclipse for now. So I'm not sure if my result is the right one) Anyway I'm not able to understand what am I doing wrong. I'm surely forgetting something. This is my code: public class ImageZoomView extends View implements OnGestureListener { private static final int SCALING_FACTOR = 50; private final int LANDSCAPE = 1;

Can a fragment extend a fragment activity? [Android]

▼魔方 西西 提交于 2019-12-08 08:30:24
问题 I have created a MainActivity which consists of 3 tabs which are scrollable (by using ViewPager). Now each of these 3 tabs is a Fragment. Also, I am using ActionBarSherlock (ABS). For the 1st Fragment, I have created the following class: public class Fragment_1 extends SherlockFragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // TODO Auto-generated method stub View v = inflater.inflate(R.layout.fragment1, container, false)

工具导航Map

JSON相关