onactivityresult

How to manage activity with startActivityForResult

给你一囗甜甜゛ 提交于 2019-11-29 17:02:11
I got a situation like this: Activity A --> B --> C --> D, when D finished, I have to refresh ActivityA to display what I input in ActivityB , ActivityC and ActivityD.Here is my code: ActivityA @OnClick(R.id.btn_one) public void toActivityB(){ Intent intent = new Intent(); intent.setClass(this, ActivityB.class); startActivityForResult(intent, 1); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == 1 && resultCode == RESULT_OK){ String b = data.getStringExtra("b"); String c = data

Where should onActivityResult be handled, dialog fragment, fragment, or activity?

旧城冷巷雨未停 提交于 2019-11-29 16:20:33
In my android app, I have a fragment where the user can add a picture, either from gallery or from camera. I've created an alert dialog and placed it in a DialogFragment. When the user chooses an option, I call startActivityForResult. My question is, where should ideally this result be handled? (i.e. where should i place onActivityResult?) In the DialogFragment class, the host fragment, or the host activity? Does it matter? onActivityResult() will be invoked first on the Activity. After that it will be reached out to the Fragments, if you call super.onActivityResult() in your Activity. This is

super.onActivityResult inside adapter class? Android

Deadly 提交于 2019-11-29 10:18:38
问题 I have RecyclerView with very complex item, multiple buttons/images/texts. To access each button/image I set my click Listeners inside my Adapter class. But now I am trying add function to set contact ringtone and I have a problem. I am calling the onActivityResult method like this: Intent contactIntent = new Intent(Intent.ACTION_PICK); contactIntent.setType(ContactsContract.Contacts.CONTENT_TYPE); contactIntent.putExtra("RINGTONE_POSITION", position); ((Activity) context)

Android Camera OnActivityResult resets photo path to null

醉酒当歌 提交于 2019-11-28 14:32:45
I'm having a problem while testing my app on a friends Galaxy S4 (GT i9505, Android 5.1). When giving a file URI to camera intent, OnActivityResult gives result Activity.RESULT_OK and and the path is null . It is working on most of other devices I tested (LG G3, nexus 5...). This is my code: GetOutputMediaFile public File getOutputMediaFile(int type){ File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM), MediaChooserConstants.folderName); if (! mediaStorageDir.exists()){ if (! mediaStorageDir.mkdirs()){ return null; } } // Create a media

Fragments startActivityForResult always return resultCode 0 and intent null on callback onActivityResult

主宰稳场 提交于 2019-11-28 13:57:21
I searched all over and there are similar posts about it, but can't find a solution! My situation is I have an Activity A that holds a fragment , and from that fragment I want to start a new Activity B that should return some values to the fragment . On the fragment startActivityForResult(mapIntent, ConstantsUtils.TOMAP_REQUEST_CODE); On the Activity B, to return the data Intent returnIntent = new Intent(); returnIntent.putExtra(SerializationConstants.isSearchSaved, mAbItemsShown.ordinal()); setResult (ConstantsUtils.SUCCESS_RETURN_CODE, returnIntent); finish(); On the fragment @Override

onActivityResult() not being called in activity

余生颓废 提交于 2019-11-28 12:41:50
问题 I have looked at several examples and I cant find what I am doing wrong. my onActivityResult() method is not being called on my activity; TransactionFormActivity is starting up a new activity called VehicleSearchActivity which has a customListAdapter.when I click on an item in that adapter I want to pass a value back to the TransactionFormActivity . here is the code from my two activities: Code in Custom List Adapter onClick() convertView.setOnClickListener(new OnClickListener() { @Override

android reduce file size for camera captured image to be less than 500 kb

主宰稳场 提交于 2019-11-28 09:01:15
My requirement is to upload camera captured image to the server, but it should be less than 500 KB. In case, if it is greater than 500 KB, it needs to be reduced to the size less than 500 KB (but somewhat closer to it) For this, I am using the following code - @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { try { super.onActivityResult(requestCode, resultCode, data); if (resultCode == getActivity().RESULT_OK) { if (requestCode == REQUEST_CODE_CAMERA) { try { photo = MediaStore.Images.Media.getBitmap( ctx.getContentResolver(), capturedImageUri); String

How to use onActivityResult method from other than Activity class

三世轮回 提交于 2019-11-27 22:01:37
I am creating an app where i need to find current location of user . So here I would like to do a task like when user returns from that System intent, my task should be done after that.(Displaying users current location) So i am planning to use OnActivityResult() . protected void onActivityResult(int requestCode, int resultCode, Intent data) { } But the problem is that I don't know how can I use that method in a class which is not extending Activity. Please some one give me idea how can i achieve this? You need an Activity on order to receive the result. If its just for organisation of code

zxing onActivityResult not called in Fragment only in Activity

烂漫一生 提交于 2019-11-27 19:18:31
问题 I'm having some issue with zxing onActivityResult(). As you can see in the code I did properly invoke new intent as described in https://code.google.com/p/zxing/wiki/ScanningViaIntent. The question is how can I catch onActivityResult() in Fragment, since I need this data in my Fragmnet and not in Activity? package com.example.testingcodereading; import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.pm.ResolveInfo; import android.os.Bundle; import

onActivityResult not call in the Fragment

喜你入骨 提交于 2019-11-27 15:09:43
The structure of the app is like this: tabHost (in Activity) -> contains -> TabFragment(extend base container fragment) 1. The code in Activity : tabHost.addTab( tabHost.newTabSpec("home").setIndicator("", getResources().getDrawable(R.drawable.btn_home)), HomeFragment.class, null); 2. The code in HomeFragment (Notice that HomeFragment is not the actual function but a container like this, and it extend BaseContainerFragment): public class HomeFragment extends BaseContainerFragment { public Home homeFrag; private boolean mIsViewInited; @Override public View onCreateView(LayoutInflater inflater,