Activity startActivityForResult - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Activity startActivityForResult method.

This code example shows how to use the following methods:startActivityForResult
8
CodeRank
This code example shows how to use the following methods:startActivityForResult
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, languageModel);
        intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 1);
        intent.putExtra(RecognizerIntent.EXTRA_PROMPT, ContextManager.getContext().getString(prompt));
        String detailMessage = "Error! No Fragment or Activity was registered to handle this voiceinput-request!";
        if (activity != null)
            activity.startActivityForResult(intent, requestCode);
        else if (fragment != null)
            fragment.startActivityForResult(intent, requestCode);
        else 
            Log.e("Astrid VoiceInputAssistant", detailMessage, new IllegalStateException(detailMessage));
    } 
 
    /** 
     * This callback-method has to be called from Fragment.onActivityResult within your fragment 
     * with parameters directly on passthru.<br> 
     * You can check in your fragment if it was really a RecognizerIntent that was handled here, 
     * if so, this method returns true. In this case, you should call super.onActivityResult in your 
     * fragment.onActivityResult. 
     * <p> 
     * If this method returns false, then it wasnt a request with a RecognizerIntent, so you can handle 
6
CodeRank
This code example shows how to use the following methods:startActivityForResult, setAction
        this.context = ContextManager.getContext().getApplicationContext();
    } 
 
    public void checkIsTTSInstalled() { 
        if (!isTTSInitialized && context instanceof Activity) {
            Intent checkIntent = new Intent();
            checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
            ((Activity) context).startActivityForResult(checkIntent,
                    MY_DATA_CHECK_CODE);
        } 
    } 
 
    public boolean handleActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == MY_DATA_CHECK_CODE) {
            if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
                // success, create the TTS instance 
                initTTS(); 
            } else { 
                // missing data, install it 
                Intent installIntent = new Intent();
8
CodeRank
This code example shows how to use the following methods:startActivityForResult, getString
    public boolean showIntent(Intent intent, IntentCallback callback, int errorId) {
        int requestCode = REQUEST_CODE_PREFIX + mNextRequestCode;
        mNextRequestCode = (mNextRequestCode + 1) % REQUEST_CODE_RANGE_SIZE;
 
        try { 
            mActivity.startActivityForResult(intent, requestCode);
        } catch (ActivityNotFoundException e) {
            return false; 
        } 
 
        mOutstandingIntents.put(requestCode, callback);
        mIntentErrors.put(requestCode, mActivity.getString(errorId));
 
        return true; 
    } 
 
    /** 
     * Displays an error message with a provided error message string. 
     * @param error The error message string to be displayed. 
     */ 
6
CodeRank
This code example shows how to use the following methods:startActivityForResult
   * @param code Request code for the activity 
   * @see android.app.Activity#startActivityForResult(Intent, int) 
   * @see android.app.Fragment#startActivityForResult(Intent, int) 
   */ 
  protected void startActivityForResult(Intent intent, int code) {
    activity.startActivityForResult(intent, code);
  } 
   
  private String findTargetAppPackage(Intent intent) {
    PackageManager pm = activity.getPackageManager();
    List<ResolveInfo> availableApps = pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
    if (availableApps != null) {
      for (ResolveInfo availableApp : availableApps) {
        String packageName = availableApp.activityInfo.packageName;
        if (targetApplications.contains(packageName)) {
          return packageName;
        } 
      } 
    } 
    return null; 
6
CodeRank
This code example shows how to use the following methods:startActivityForResult
This code example shows how to use the following methods:startActivityForResult
		if (bluetoothAdapter == null) {
			return BLUETOOTH_NOT_SUPPORTED;// Device does not support Bluetooth
		} 
		if (!bluetoothAdapter.isEnabled()) {
			Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
			activity.startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
			return BLUETOOTH_ACTIVATING;
		} else { 
			//Log.d("TAG", "LOOP!!!!!"); 
			//connectLegoNXT(); 
			return BLUETOOTH_ALREADY_ON;
		} 
	} 
} 
5
CodeRank
This code example shows how to use the following methods:startActivityForResult
		return pairing;
	} 
 
	public void connectLegoNXT() { 
		Intent serverIntent = new Intent(this.activity, DeviceListActivity.class);
		activity.startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE);
 
	} 
} 
5
CodeRank
This code example shows how to use the following methods:runOnUiThread, startActivityForResult
    } 
 
	void connectCurrentClient() { 
        switch (mClientCurrentlyConnecting) {
            case CLIENT_GAMES:
            	mParentActivity.runOnUiThread(new Runnable() {
 
					public void run() { 
						mGamesClient.connect();
					}            		 
            	}); 
                 
                break; 
            case CLIENT_APPSTATE:
            	mParentActivity.runOnUiThread(new Runnable() {
					public void run() { 
						mAppStateClient.connect();
					} 
            	}); 
                 

5
CodeRank
This code example shows how to use the following methods:startActivityForResult
		return pairing;
	} 
 
	public void connectLegoNXT() { 
		Intent serverIntent = new Intent(this.activity, DeviceListActivity.class);
		activity.startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE);
 
	} 
} 
5
CodeRank

Related Activity startActivityForResult Questions & Answers:

Other Activity startActivityForResult Examples

30:	    intent.setAction(Intent.ACTION_GET_CONTENT);
31:	    intent.addCategory(Intent.CATEGORY_OPENABLE);
32:	    startActivityForResult(intent, REQUEST_CODE);
33:	  }
34:

Read More

107:	
108:			// start the image capture Intent
109:			startActivityForResult(intent, CAMERA_CAPTURE_IMAGE_REQUEST_CODE);
110:		}
111:	
-
146:	
147:			// start the video capture Intent
148:			startActivityForResult(intent, CAMERA_CAPTURE_VIDEO_REQUEST_CODE);
149:		}
150:

Read More

13:	
14:			// start the video capture Intent
15:			startActivityForResult(intent, CAMERA_CAPTURE_VIDEO_REQUEST_CODE);
16:		}
17:

Read More

9:	
10:			// start the image capture Intent
11:			startActivityForResult(intent, CAMERA_CAPTURE_IMAGE_REQUEST_CODE);
12:		}
13:

Read More

16:	        getResources().getString(R.string.device_admin_activation_message));
17:	
18:	    startActivityForResult(activateDeviceAdminIntent,
19:	        REQ_ACTIVATE_DEVICE_ADMIN);
20:	}

Read More

startActivityForResult Method Overview
Same as calling startActivityForResult(Intent, int, Bundle) with no options.
See Code Examples for other Android Activity Methods: