Intent setAction - top ranked examples from Open Source projects

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

This code example shows how to use the following methods:addFlags, setAction
 
    @Override 
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:  // See ActionBar#setDisplayHomeAsUpEnabled()
                Intent intent = new Intent(this, FdnSetting.class);
                intent.setAction(Intent.ACTION_MAIN);
                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(intent);
                finish(); 
                return true; 
 
            case MENU_ADD:
                addContact(); 
                return true; 
 
            case MENU_EDIT:
                editSelected(); 
                return true; 
 
8
CodeRank
This code example shows how to use the following methods:setAction
    if (this.wakeLock.isHeld())
      this.wakeLock.release();
  } 
 
  private void issueConnectivityChange() { 
    Intent intent = new Intent(context, SendReceiveService.class);
    intent.setAction(getConnectivityAction());
    context.startService(intent);
  } 
 
  private class ConnectivityListener extends BroadcastReceiver {
    @Override 
    public void onReceive(Context context, Intent intent) {
      Log.w("MmsService", "Dispatching connectivity change...");
      issueConnectivityChange(); 
      Log.w("MmsService", "Dispatched...");
    } 
  } 
} 
7
CodeRank
This code example shows how to use the following methods:putExtra, setAction, sleep
        signer.update(requiredPrevious.trim().getBytes());
        return signer.verify(Base64.decode(signature.getBytes(), Base64.DEFAULT));
    } 
 
    private void sendIntent(String contentPath, String version, String required, String sig) {
        Intent i = new Intent();
        i.setAction("android.intent.action.UPDATE_PINS");
        i.putExtra(EXTRA_CONTENT_PATH, contentPath);
        i.putExtra(EXTRA_VERSION_NUMBER, version);
        i.putExtra(EXTRA_REQUIRED_HASH, required);
        i.putExtra(EXTRA_SIGNATURE, sig);
        mContext.sendBroadcast(i);
    } 
 
    private String runTest(String cert, String content, String version, String required, String sig)
                           throws Exception { 
        Log.e(TAG, "started test");
        overrideCert(cert);
        String contentPath = makeTemporaryContentFile(content);
        sendIntent(contentPath, version, required, sig);

7
CodeRank
This code example shows how to use the following methods:putExtra, setAction
     * @param passphrase 
     */ 
    public static void addCachedPassphrase(Context context, long keyId, String passphrase) {
        Log.d(TAG, "cacheNewPassphrase() for " + keyId);
 
        Intent intent = new Intent(context, PassphraseCacheService.class);
        intent.setAction(ACTION_PASSPHRASE_CACHE_ADD);
        intent.putExtra(EXTRA_TTL, Preferences.getPreferences(context).getPassPhraseCacheTtl());
        intent.putExtra(EXTRA_PASSPHRASE, passphrase);
        intent.putExtra(EXTRA_KEY_ID, keyId);
 
        context.startService(intent);
    } 
 
    /** 
     * Gets a cached passphrase from memory, blocking method 
     *  
     * @param context 
     * @param keyId 
     * @return 
7
CodeRank
This code example shows how to use the following methods:setAction
 
  protected void finishConnectivity() { 
    Log.w("MmsService", "Calling stop using network feature!");
    connectivityManager.stopUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE, FEATURE_ENABLE_MMS);
 
    if (connectivityListener != null) {
      context.unregisterReceiver(connectivityListener);
      connectivityListener = null;
    } 
 
    if (this.wakeLock.isHeld())
      this.wakeLock.release();
  } 
 
  private void issueConnectivityChange() { 
    Intent intent = new Intent(context, SendReceiveService.class);
    intent.setAction(getConnectivityAction());
    context.startService(intent);
  } 
 
7
CodeRank
This code example shows how to use the following methods:putExtra, setAction
				i.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
				result.putParcelable(AccountManager.KEY_INTENT, i);
				return result;
			} else { 
				result = new Bundle();
				Intent i = new Intent(mContext, LastFm.class);
				i.setAction("fm.last.android.sync.LOGIN");
				i.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
				result.putParcelable(AccountManager.KEY_INTENT, i);
			}			 
			return result;
		} 
 
		/* (non-Javadoc) 
		 * @see android.accounts.AbstractAccountAuthenticator#confirmCredentials(android.accounts.AccountAuthenticatorResponse, android.accounts.Account, android.os.Bundle) 
		 */ 
		@Override 
		public Bundle confirmCredentials(AccountAuthenticatorResponse response, Account account, Bundle options) {
			// TODO Auto-generated method stub 
			Log.i(TAG, "confirmCredentials");
7
CodeRank
This code example shows how to use the following methods:setAction, setPackage
          // no-op -- client must be gone 
        } 
      } 
    } 
    else { 
      data.setPackage(intent.getStringExtra(BROADCAST_PACKAGE));
      data.setAction(broadcast);
 
      sendBroadcast(data);
    } 
  } 
   
  private String getStackTrace(Throwable t) {
    final StringWriter result=new StringWriter();
    final PrintWriter printWriter=new PrintWriter(result);
     
    t.printStackTrace(printWriter);
     
    return(result.toString());
  } 
7
CodeRank
This code example shows how to use the following methods:setAction, setType
        telop.setTypeface(Typeface.DEFAULT, 1);
        mFrameLayout.addView(telop);
    } 
 
    public void onPickVideoButton(View view) {
        Intent intent = new Intent();
        intent.setType("video/*");
        intent.setAction(Intent.ACTION_GET_CONTENT);
        startActivityForResult(intent, 1);
    } 
 
    protected void onActivityResult(int requestCode,
                                    int resultCode, Intent data) {
        if (resultCode == RESULT_OK && requestCode == 1) {
            Uri uri = data.getData();
            mVideoView.setVideoURI(uri);
        } 
    } 
} 
7
CodeRank
This code example shows how to use the following methods:putExtra, setAction
		} 
	} 
 
	@Nonnull 
	public static Intent newButtonClickedIntent(@Nonnull Context context, @Nonnull CalculatorButton button) {
		final Intent intent = new Intent(context, CalculatorReceiver.class);
		intent.setAction(ACTION_BUTTON_PRESSED);
		intent.putExtra(ACTION_BUTTON_ID_EXTRA, button.getButtonId());
		return intent;
	} 
} 
7
CodeRank
This code example shows how to use the following methods:putExtra, setAction
			NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
			Log.d(TAG, "ACTIVE NetworkInfo: "+(networkInfo != null ? networkInfo.toString() : "NONE"));
			if (((networkInfo == null) && (networkType != -1)) || ((networkInfo != null) && (networkInfo.isConnected() == false) && (networkInfo.getType() == networkType))) {
				Log.d(TAG, "we got disconnected");
				networkType = -1;
				Intent xmppServiceIntent = new Intent(context, XMPPService.class);
				xmppServiceIntent.setAction("de.hdmstuttgart.yaxim.XMPPSERVICE");
				xmppServiceIntent.putExtra("disconnect", true);
				context.startService(xmppServiceIntent);
			} 
			if ((networkInfo != null) && (networkInfo.isConnected() == true) && (networkInfo.getType() != networkType)) {
				Log.d(TAG, "we got connected");
				networkType = networkInfo.getType();
				Intent xmppServiceIntent = new Intent(context, XMPPService.class);
				xmppServiceIntent.setAction("de.hdmstuttgart.yaxim.XMPPSERVICE");
				xmppServiceIntent.putExtra("reconnect", true);
				context.startService(xmppServiceIntent);
			} else 
			if ((networkInfo != null) && (networkInfo.isConnected() == true) && (networkInfo.getType() == networkType)) {
				Log.d(TAG, "we stay connected, sending a ping");
7
CodeRank

Related Intent setAction Questions & Answers:

Other Intent setAction Examples

28:	    Intent intent = new Intent();
29:	    intent.setType("image/*");
30:	    intent.setAction(Intent.ACTION_GET_CONTENT);
31:	    intent.addCategory(Intent.CATEGORY_OPENABLE);
32:	    startActivityForResult(intent, REQUEST_CODE);

Read More

setAction Method Overview
Set the general action to be performed.
See Code Examples for other Android Intent Methods: