onactivityresult

Handle data from several activities in one onActivityResult()?

折月煮酒 提交于 2019-12-19 02:47:11
问题 I wonder if it's possible to handle data from e.g. activity 2 and activity 3 in activity 1 that have one onActivityResult() , or do I need to have one method for each activity that return data? Activity 1 is the main activity for the application. Activity 1: // Handle return value from activity protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { String imageId = data.getExtras().getString("imageId"); // Do something if data

ACTION_INSTALL_PACKAGE

我怕爱的太早我们不能终老 提交于 2019-12-18 12:30:10
问题 My app is trying to install an APK. Intent installIntent = new Intent(Intent.ACTION_INSTALL_PACKAGE); installIntent.setData(Uri.fromFile(new File(pathToApk))); installIntent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true); installIntent.putExtra(Intent.EXTRA_RETURN_RESULT, true); installIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); ((Activity)context).startActivityForResult(installIntent, Constants.APP_INSTALL_REQUEST); In my Activity protected void onActivityResult(int requestCode, int

values are set to null after onActivityResult

三世轮回 提交于 2019-12-13 18:19:46
问题 I have a DialogFragment class with a custom xml layout. In onCreateView() I get reference to a button. You click it to choose file. When it's clicked two things happen: 1) It uses a layout inflater to add another xml layout into the current one 2) It initializes three variables to their values ListView , ListArray , SimpleAdapter , and these are member variables declared at the top of the class. 3) Then it calls getActivity().startActivityForResult() Problem: The three variables described

Error with resultCode in onActivityForResult after calling startActivityForResult

别说谁变了你拦得住时间么 提交于 2019-12-13 00:22:45
问题 I am enabling Bluetooth services through an Intent and calling startActivityForResult() method as follows: public void enableBT(BluetoothAdapter adapter) { if (!adapter.isEnabled()) { Intent enableBTIntent = new Intent( BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE); startActivityForResult(enableBTIntent, ENABLE_BT_INTENT); } } In this code, adapter is BluetoothAdapter object. After this I call onActivityResult() as follows: protected void onActivityResult(int requestCode, int resultCode,

Why doesn't startActivityForResult return anything?

空扰寡人 提交于 2019-12-12 14:32:29
问题 I have a "Select image" in a PreferenceActivity: Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(i, IMAGE_SELECT); But when I pick an image from Gallery, it does not return anything to my PreferenceActivity 's onActivityResult : @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { Toast.makeText(getApplicationContext(), "THIS TOAST IS NOT SHOWING", Toast.LENGTH_LONG).show(); }

onActivityResult is not called when the back button in ActionBar is clicked

大憨熊 提交于 2019-12-12 12:17:08
问题 Here is my problem: Create a MainActivity. Add a button which will start another activity SecondActivity. Intent i = new Intent(getActivity(),SecondActivity.class); startActivityForResult(i,0); Inside the SecondActivity, I capture the back button click event and also add a button to return to the first Activity. When back button in action bar is clicked: @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: // back button Intent

How to pass intent extras to onactivityresult when activity reboot?

夙愿已清 提交于 2019-12-12 04:55:21
问题 I am writing an android application. Need to pass int value.I have a listview that it has contextmenu.I must start Intent.Action_Call. When I start my intent. My application is going to background. When intent is finish my application start a survey.My problem is ;I am not getting user"s clicked position.I tried insert to putExtra but in onActivityResult void does not accepted value of my user"s clicked position and value become zero.How can I get ıt ? public boolean onContextItemSelected

Android openFileChooser onCreate() called after onActivityResult()

╄→尐↘猪︶ㄣ 提交于 2019-12-12 04:50:03
问题 I have a webview and on one of the pages there is an Upload Photo button. I found some code to implement the file chooser (Android, why so hard????) and if I pick the gallery everything works fine. If I choose camera 1 of 10 times it works. But most of the time when I take the picture and click save (this is all in the camera activity) the webview loads the first page loaded when the app was started. It seems that the onActivityResult() is not called but instead of it onCreate() is and this

How to play recorded audio file from 'onActivityResult()'?

二次信任 提交于 2019-12-12 04:35:50
问题 I'm using this library to record audio in my app. Here's my code: recordDefectAudio.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (ContextCompat.checkSelfPermission(getBaseContext(), android.Manifest.permission.RECORD_AUDIO) + ContextCompat.checkSelfPermission(getBaseContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(MainActivity.this, new String[]{android.Manifest

Select Image From Gallery And Display It On ImageView, Issue On Nexus 5

拟墨画扇 提交于 2019-12-12 03:23:10
问题 I have a very weird issue, I want the user to select an image and display it on a ImageView, the code works perfectly on my Xiaomi mi52 (V4.1.1) and my Xiaomi MiPad (V4.4.4) but it's totally failed on my Nexus 5 (V5.0). public class CreateContactActivity extends Activity { private ImageView imgProfile; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_create_contact); imgProfile = (ImageView)findViewById(R.id