android.content.Intent.getStringArrayExtra()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(11.0k)|赞(0)|评价(0)|浏览(416)

本文整理了Java中android.content.Intent.getStringArrayExtra()方法的一些代码示例,展示了Intent.getStringArrayExtra()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Intent.getStringArrayExtra()方法的具体详情如下:
包路径:android.content.Intent
类名称:Intent
方法名:getStringArrayExtra

Intent.getStringArrayExtra介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

public void onCreate() {
 Intent intent = getIntent();
 String[] myStrings = intent.getStringArrayExtra("strings");
}

代码示例来源:origin: stackoverflow.com

public class UninstallIntentReceiver extends BroadcastReceiver{

  @Override
  public void onReceive(Context context, Intent intent) {
    // fetching package names from extras
    String[] packageNames = intent.getStringArrayExtra("android.intent.extra.PACKAGES"); 

    if(packageNames!=null){
      for(String packageName: packageNames){
        if(packageName!=null && packageName.equals("YOUR_APPLICATION_PACKAGE_NAME")){
          // User has selected our application under the Manage Apps settings
          // now initiating background thread to watch for activity
          new ListenActivities(context).start();

        }
      }
    }
  }

}

代码示例来源:origin: pockethub/PocketHub

/**
 * Get intent extra
 *
 * @param name
 * @return string array
 */
protected String[] getStringArrayExtra(final String name) {
  return getIntent().getStringArrayExtra(name);
}

代码示例来源:origin: android-hacker/VirtualXposed

/**
 * Return a set of account types specified by the intent as well as supported by the
 * AccountManager.
 */
private Set<String> getReleventAccountTypes(final Intent intent) {
  // An account type is relevant iff it is allowed by the caller and supported by the account
  // manager.
  Set<String> setOfRelevantAccountTypes;
  final String[] allowedAccountTypes =
      intent.getStringArrayExtra(EXTRA_ALLOWABLE_ACCOUNT_TYPES_STRING_ARRAY);
  AuthenticatorDescription[] descs = VAccountManager.get().getAuthenticatorTypes();
  Set<String> supportedAccountTypes = new HashSet<String>(descs.length);
  for (AuthenticatorDescription desc : descs) {
    supportedAccountTypes.add(desc.type);
  }
  if (allowedAccountTypes != null) {
    setOfRelevantAccountTypes = new HashSet<>();
    Collections.addAll(setOfRelevantAccountTypes, allowedAccountTypes);
    setOfRelevantAccountTypes.retainAll(supportedAccountTypes);
  } else {
    setOfRelevantAccountTypes = supportedAccountTypes;
  }
  return setOfRelevantAccountTypes;
}

代码示例来源:origin: android-hacker/VirtualXposed

private void startChooseAccountTypeActivity() {
  VLog.v(TAG, "ChooseAccountTypeActivity.startChooseAccountTypeActivity()");
  final Intent intent = new Intent(this, ChooseAccountTypeActivity.class);
  intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
  intent.putExtra(EXTRA_ALLOWABLE_ACCOUNT_TYPES_STRING_ARRAY,
      getIntent().getStringArrayExtra(EXTRA_ALLOWABLE_ACCOUNT_TYPES_STRING_ARRAY));
  intent.putExtra(EXTRA_ADD_ACCOUNT_OPTIONS_BUNDLE,
      getIntent().getBundleExtra(EXTRA_ADD_ACCOUNT_OPTIONS_BUNDLE));
  intent.putExtra(EXTRA_ADD_ACCOUNT_REQUIRED_FEATURES_STRING_ARRAY,
      getIntent().getStringArrayExtra(EXTRA_ADD_ACCOUNT_REQUIRED_FEATURES_STRING_ARRAY));
  intent.putExtra(EXTRA_ADD_ACCOUNT_AUTH_TOKEN_TYPE_STRING,
      getIntent().getStringExtra(EXTRA_ADD_ACCOUNT_AUTH_TOKEN_TYPE_STRING));
  startActivityForResult(intent, REQUEST_CHOOSE_TYPE);
  mPendingRequest = REQUEST_CHOOSE_TYPE;
}

代码示例来源:origin: k9mail/k-9

public void initFromSendOrViewIntent(Intent intent) {
  String[] extraEmail = intent.getStringArrayExtra(Intent.EXTRA_EMAIL);
  String[] extraCc = intent.getStringArrayExtra(Intent.EXTRA_CC);
  String[] extraBcc = intent.getStringArrayExtra(Intent.EXTRA_BCC);
  if (extraEmail != null) {
    addToAddresses(addressFromStringArray(extraEmail));
  }
  if (extraCc != null) {
    addCcAddresses(addressFromStringArray(extraCc));
  }
  if (extraBcc != null) {
    addBccAddresses(addressFromStringArray(extraBcc));
  }
}

代码示例来源:origin: TeamNewPipe/NewPipe

if (action != null) {
  if (action.equals(Intent.ACTION_RUN)) {
    String[] urls = intent.getStringArrayExtra(EXTRA_URLS);
    String name = intent.getStringExtra(EXTRA_NAME);
    String location = intent.getStringExtra(EXTRA_LOCATION);
    char kind = intent.getCharExtra(EXTRA_KIND, '?');
    String psName = intent.getStringExtra(EXTRA_POSTPROCESSING_NAME);
    String[] psArgs = intent.getStringArrayExtra(EXTRA_POSTPROCESSING_ARGS);
    String source = intent.getStringExtra(EXTRA_SOURCE);
    long nearLength = intent.getLongExtra(EXTRA_NEAR_LENGTH, 0);

代码示例来源:origin: android-hacker/VirtualXposed

protected void runAddAccountForAuthenticator(String type) {
  if (Log.isLoggable(TAG, Log.VERBOSE)) {
    Log.v(TAG, "runAddAccountForAuthenticator: " + type);
  }
  final Bundle options = getIntent().getBundleExtra(
      ChooseTypeAndAccountActivity.EXTRA_ADD_ACCOUNT_OPTIONS_BUNDLE);
  final String[] requiredFeatures = getIntent().getStringArrayExtra(
      ChooseTypeAndAccountActivity.EXTRA_ADD_ACCOUNT_REQUIRED_FEATURES_STRING_ARRAY);
  final String authTokenType = getIntent().getStringExtra(
      ChooseTypeAndAccountActivity.EXTRA_ADD_ACCOUNT_AUTH_TOKEN_TYPE_STRING);
  VAccountManager.get().addAccount(mCallingUserId, type, authTokenType, requiredFeatures,
      options, null /* activity */, this /* callback */, null /* Handler */);
}

代码示例来源:origin: TommyLemon/APIJSON

private void init() {
  llTopMenuWindowBg = findViewById(R.id.llTopMenuWindowBg);
  llTopMenuWindowBg.setOnClickListener(this);
  Intent intent = getIntent();
  int[] intentCodes = intent.getIntArrayExtra(INTENT_INTENTCODES);
  if (intentCodes == null || intentCodes.length <= 0) {
    intentCodeList = intent.getIntegerArrayListExtra(INTENT_INTENTCODES);
  } else {
    intentCodeList = new ArrayList<Integer>();
    for (int code : intentCodes) {
      intentCodeList.add(code);
    }
  }
  String[] menuItems = intent.getStringArrayExtra(INTENT_NAMES);
  if (menuItems == null || menuItems.length <= 0) {
    nameList = intent.getStringArrayListExtra(INTENT_NAMES);
  } else {
    nameList = new ArrayList<String>(Arrays.asList(menuItems));
  }
  if (nameList == null || nameList.size() <= 0) {
    Log.e(TAG, "init   nameList == null || nameList.size() <= 0 >> finish();return;");
    finish();
    return;
  }
  adapter = new ArrayAdapter<String>(this, R.layout.top_menu_list_item, R.id.tvTopMenuListItem, nameList);
  lvTopMenu = (ListView) findViewById(R.id.lvTopMenuWindowMenu);
  lvTopMenu.setAdapter(adapter);
  lvTopMenu.setOnItemClickListener(this);
}

代码示例来源:origin: TommyLemon/Android-ZBLibrary

private void init() {
  llTopMenuWindowBg = findViewById(R.id.llTopMenuWindowBg);
  llTopMenuWindowBg.setOnClickListener(this);
  Intent intent = getIntent();
  int[] intentCodes = intent.getIntArrayExtra(INTENT_INTENTCODES);
  if (intentCodes == null || intentCodes.length <= 0) {
    intentCodeList = intent.getIntegerArrayListExtra(INTENT_INTENTCODES);
  } else {
    intentCodeList = new ArrayList<Integer>();
    for (int code : intentCodes) {
      intentCodeList.add(code);
    }
  }
  String[] menuItems = intent.getStringArrayExtra(INTENT_NAMES);
  if (menuItems == null || menuItems.length <= 0) {
    nameList = intent.getStringArrayListExtra(INTENT_NAMES);
  } else {
    nameList = new ArrayList<String>(Arrays.asList(menuItems));
  }
  if (nameList == null || nameList.size() <= 0) {
    Log.e(TAG, "init   nameList == null || nameList.size() <= 0 >> finish();return;");
    finish();
    return;
  }
  adapter = new ArrayAdapter<String>(this, R.layout.top_menu_list_item, R.id.tvTopMenuListItem, nameList);
  lvTopMenu = findViewById(R.id.lvTopMenuWindowMenu);
  lvTopMenu.setAdapter(adapter);
  lvTopMenu.setOnItemClickListener(this);
}

代码示例来源:origin: TommyLemon/APIJSON

String[] menuItems = intent.getStringArrayExtra(INTENT_ITEMS);
if (menuItems == null || menuItems.length <= 0) {
  nameList = intent.getStringArrayListExtra(INTENT_ITEMS);

代码示例来源:origin: android-hacker/VirtualXposed

String[] validAccountTypes = getIntent().getStringArrayExtra(
    ChooseTypeAndAccountActivity.EXTRA_ALLOWABLE_ACCOUNT_TYPES_STRING_ARRAY);
if (validAccountTypes != null) {

代码示例来源:origin: TommyLemon/Android-ZBLibrary

String[] menuItems = intent.getStringArrayExtra(INTENT_ITEMS);
if (menuItems == null || menuItems.length <= 0) {
  nameList = intent.getStringArrayListExtra(INTENT_ITEMS);

代码示例来源:origin: termux/termux-app

String executablePath = (executableUri == null ? null : executableUri.getPath());
String[] arguments = (executableUri == null ? null : intent.getStringArrayExtra(EXTRA_ARGUMENTS));
String cwd = intent.getStringExtra(EXTRA_CURRENT_WORKING_DIRECTORY);

代码示例来源:origin: LawnchairLauncher/Lawnchair

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  // Don't continue if the activity doesn't have an intent
  if (getIntent() == null) {
    finish();
    return;
  }
  // Get permissions array which we want to request
  resultReceiver = getIntent().getParcelableExtra("resultReceiver");
  String[] permissionsArray = getIntent().getStringArrayExtra("permissions");
  int requestCode = getIntent().getIntExtra("requestCode", REQUEST_CODE);
  // Check if those permissions are already granted
  if (PermissionResponse.hasPermissions(this, permissionsArray)) {
    // Proceed like those permissions have been now granted
    onComplete(requestCode, permissionsArray, new int[]{ PackageManager.PERMISSION_GRANTED });
  } else {
    // Otherwise request those permissions and wait for users response
    ActivityCompat.requestPermissions(this, permissionsArray, requestCode);
  }
}

代码示例来源:origin: wangdan/AisenWeiBo

@Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode == Activity.RESULT_OK && requestCode == 2000) {
      String[] pics = data.getStringArrayExtra("images");

      selectedFile.clear();
      for (String pic : pics) {
        selectedFile.add(pic);
      }
//            btnCounter.setVisibility(selectedFile.size() == 0 ? View.GONE : View.VISIBLE);
//            txtCounter.setText(String.format("预览(%d/%d)", selectedFile.size(), maxSize));
      getAdapter().notifyDataSetChanged();
      getActivity().invalidateOptionsMenu();

      // 如果在预览已经确定了,就直接返回数据
      if (data.getBooleanExtra("confirm", false)) {
        savePics();
      }
    }
    // 设置头像成功
    else if (resultCode == Activity.RESULT_OK && requestCode == 3000) {
      getActivity().finish();
    }
  }

代码示例来源:origin: TeamNewPipe/NewPipe

returnActivity = ac.returnActivity;
errorInfo = intent.getParcelableExtra(ERROR_INFO);
errorList = intent.getStringArrayExtra(ERROR_LIST);

代码示例来源:origin: aa112901/remusic

break;
case ADD_MULTI_DOWNTASK:
  String[] names = intent.getStringArrayExtra("names");
  String[] artists = intent.getStringArrayExtra("artists");
  ArrayList<String> urls = intent.getStringArrayListExtra("urls");
  addDownloadTask(names, artists, urls);

代码示例来源:origin: wangdan/AisenWeiBo

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
  super.onActivityResult(requestCode, resultCode, data);
  
  if (requestCode == 1000 && resultCode == Activity.RESULT_OK) {
    WeiBoUser user = (WeiBoUser) data.getSerializableExtra("bean");
    
    Editable editAble = editContent.getEditableText();
    int start = editContent.getSelectionStart();
    editAble.insert(start, String.format("@%s ", user.getScreen_name()));
  }
  else if (requestCode == 3333 && resultCode == Activity.RESULT_OK) {
    if (data != null) {
      String[] pics = data.getStringArrayExtra("pics");
      if (pics != null) {
        getPublishBean().setPics(pics);
        onPicChanged(pics);
        refreshUI();
      }
    }
  }
  else {
    if (photoChoice != null)
      photoChoice.onActivityResult(requestCode, resultCode, data);
  }
  
}

代码示例来源:origin: Genymobile/gnirehtet

private static VpnConfiguration createConfig(Intent intent) {
  String[] dnsServers = intent.getStringArrayExtra(EXTRA_DNS_SERVERS);
  if (dnsServers == null) {
    dnsServers = new String[0];
  }
  String[] routes = intent.getStringArrayExtra(EXTRA_ROUTES);
  if (routes == null) {
    routes = new String[0];
  }
  return new VpnConfiguration(Net.toInetAddresses(dnsServers), Net.toCIDRs(routes));
}

相关文章

Intent类方法