android-activity

How to Start an Intent for Result from a contained class of an Activity (startActivityForResult)

江枫思渺然 提交于 2020-01-15 06:51:27
问题 This is a follow up to my previous question: How to Start an Intent from a contained class of an Activity Basically, I realized that I need to call startActivityForResult (and not startActivity ) from a contained class of an Activity. The answer from the previous question passed the Context from the Activity class to the contained class. However, the context alone isn't enough to call StartActivityForResult . What is the best way to do this? Do I have to pass the entire Activity Class to the

SetResult not working when activity finished by clearTop

亡梦爱人 提交于 2020-01-15 04:59:29
问题 Overview of Problem : ActivityA starts ActivityB with startActivityForResult . ActivityB sets its result using setResult and then starts ActivityC with startActivity . ActivityC then starts the singleTop ActivityA with the CLEAR_TOP flag set. I expect this to finish ActivityB and call ActivityA's onActivityResult method. Unfortunately this method is not getting called upon the restart of ActivityA. ActivityA Code : I have started an activity (ActivityB) with startActivityForResult() with the

Android is killing my application whenever startactivityforresult is called

懵懂的女人 提交于 2020-01-15 04:42:09
问题 Well, in my application I'm using default camera and gallery of Android with startActivityforResult as; Intent i = new Intent("android.intent.action.PICK", MediaStore.Images.Media.EXTERNAL_CONTENT_URI); i.setType("image/*"); startActivityForResult(i, this.SELECT_PICTURE); I am able to catch onActivityResult as well. However, if memory is low and I start this activity, I experienced that system is killing my parent activity, and even if the activity returns with a value, I lost all my local

'Fragment already active' when setArguments() to fragment

两盒软妹~` 提交于 2020-01-15 01:53:27
问题 I have an Activity which hosts a Fragment . The Activity layout file: <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/fragment_container" android:layout_width="match_parent" android:layout_height="match_parent"> <fragment class="com.my.ContentFragment" android:id="@+id/fragment_content" android:layout_width="match_parent" android:layout_height="match_parent"/> </FrameLayout> Java code of Activity : import android.support.v4.app.Fragment; import android

Pass model object to another Activity

时光总嘲笑我的痴心妄想 提交于 2020-01-14 14:17:07
问题 I have a RecyclerView that utilizes a Recycler Adapter to output a list layout, like this: http://i.imgur.com/ORkXXTb.png I need to attach the model below to each of the list items, such that if the user clicks on any element in the list item (like the circle or one of the two TextViews), it passes the model object to the next Activity . Here is the User model: public class User { private String id; private String username; private String displayName; private Object deletedAt; private

Android: How to Resume Application/Activity from BroadcastReceiver?

半腔热情 提交于 2020-01-14 13:04:32
问题 If my procedure is following: Launch Activity A -> Activity B Press 'Home' button. Click on the application again. Result: 'Activity B' shows up (it resumes ). Launch Activity A -> Activity B Press 'Back' button. Click on the application again. Result: 'Activity A' shows up (it restarts ). I want to do exactly same from the BroadcastReceiver. Launch Activity A -> Activity B Press 'Home' button. BroadcastReceiver receives a broadcast and want to "resume" application. My expected result:

Android: How to Resume Application/Activity from BroadcastReceiver?

浪尽此生 提交于 2020-01-14 13:04:18
问题 If my procedure is following: Launch Activity A -> Activity B Press 'Home' button. Click on the application again. Result: 'Activity B' shows up (it resumes ). Launch Activity A -> Activity B Press 'Back' button. Click on the application again. Result: 'Activity A' shows up (it restarts ). I want to do exactly same from the BroadcastReceiver. Launch Activity A -> Activity B Press 'Home' button. BroadcastReceiver receives a broadcast and want to "resume" application. My expected result:

Android: How to Resume Application/Activity from BroadcastReceiver?

六月ゝ 毕业季﹏ 提交于 2020-01-14 13:04:01
问题 If my procedure is following: Launch Activity A -> Activity B Press 'Home' button. Click on the application again. Result: 'Activity B' shows up (it resumes ). Launch Activity A -> Activity B Press 'Back' button. Click on the application again. Result: 'Activity A' shows up (it restarts ). I want to do exactly same from the BroadcastReceiver. Launch Activity A -> Activity B Press 'Home' button. BroadcastReceiver receives a broadcast and want to "resume" application. My expected result:

Open a specific fragment of activity A from activity B

怎甘沉沦 提交于 2020-01-14 12:32:54
问题 Here again! The situation is this, I have: Activity A that implements a viewPager and visualizes 3 possible fragments. To access to each fragment I use this code: @Override public Fragment getItem(int page) { switch (page) { case 0: return new MyFirstFragment(); case 1: return new MySecondFragment(); case 2: return new MyThirdFragment(); } return null; } @Override public int getCount() { return [the count of total fragments]; } Fragment 3 contains a list of users. When I click on a user

adding click listener to titlebar image

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-14 08:49:06
问题 Merry Christmas and Happy Holidays everyone! I'm trying to setup a listener on the image icon that appears on the left side of the default title bar, but so far not having any luck. Here's my Activity's onCreate: @Override public void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_LEFT_ICON); super.onCreate(savedInstanceState); findViewById(Window.FEATURE_LEFT_ICON).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { System.out.println