Java Code Examples for android.content.Intent.getStringArrayExtra()

The following are Jave code examples for showing how to use getStringArrayExtra() of the android.content.Intent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: CatchSpy   File: ShowActivity.java   View Source Code Vote up 7 votes
private void getPlayerData() {
    Intent intent = getIntent();
    if (intent != null) {
        Player = intent.getIntArrayExtra(Config.INTENT_EXTRA_PLAYER);
        PlayerWords = intent.getStringArrayExtra(Config.INTENT_EXTRA_PLAYER_WORDS);
        PlayerName = intent.getStringArrayExtra(Config.INTENT_EXTRA_PLAYER_NAME);
        if (Player == null || PlayerWords == null) {
            Toast.makeText(this, R.string.data_error, Toast.LENGTH_SHORT).show();
            finish();
        } else {
            playerNumber = Player.length;
            if (PlayerName == null) {
                PlayerName = new String[playerNumber];
            } else {
                hasPlayerName = true;
                changePlayerName = true;
            }
        }
    } else {
        Toast.makeText(this, R.string.data_error, Toast.LENGTH_SHORT).show();
        finish();
    }
}
 
Example 2
Project: LucaHome-MediaServer   File: SocketListUpdater.java   View Source Code Vote up 7 votes
@Override
public void onReceive(Context context, Intent intent) {
    _logger.Debug("_updateReceiver onReceive");
    String[] socketStringArray = intent.getStringArrayExtra(Bundles.SOCKET_LIST);

    if (socketStringArray != null) {
        SerializableList<WirelessSocketDto> socketList = JsonDataToSocketConverter.GetList(socketStringArray);
        if (socketList != null) {
            _broadcastController.SendSerializableBroadcast(
                    Broadcasts.SOCKET_LIST,
                    Bundles.SOCKET_LIST,
                    socketList);
        } else {
            Toasty.error(_context, "Failed to convert socket list from string array!", Toast.LENGTH_LONG).show();
        }
    }
}
 
Example 3
Project: letv   File: ShareCompat.java   View Source Code Vote up 7 votes
private void combineArrayExtra(String extra, String[] add) {
    int oldLength;
    Intent intent = getIntent();
    String[] old = intent.getStringArrayExtra(extra);
    if (old != null) {
        oldLength = old.length;
    } else {
        oldLength = 0;
    }
    String[] result = new String[(add.length + oldLength)];
    if (old != null) {
        System.arraycopy(old, 0, result, 0, oldLength);
    }
    System.arraycopy(add, 0, result, oldLength, add.length);
    intent.putExtra(extra, result);
}
 
Example 4
Project: GravityBox   File: ModTrustManager.java   View Source Code Vote up 7 votes
@Override
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    if (action.equals(WifiPriorityActivity.ACTION_WIFI_TRUSTED_CHANGED)) {
        if (intent.hasExtra(WifiPriorityActivity.EXTRA_WIFI_TRUSTED)) {
            String[] values = intent.getStringArrayExtra(WifiPriorityActivity.EXTRA_WIFI_TRUSTED);
            if (mWifiTrusted.size() > 0 && values.length == 0) {
                mForceRefreshAgentList = true;
            }
            mWifiTrusted = new HashSet<String>(Arrays.asList(values));
            if (DEBUG) log("ACTION_WIFI_TRUSTED_CHANGED: mWifiTrusted=" + mWifiTrusted +
                    "; mForceRefreshAgentList=" + mForceRefreshAgentList);
            updateTrustAll();
        }
    } else if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
        if (intent.getIntExtra(ConnectivityManager.EXTRA_NETWORK_TYPE, -1) ==
                ConnectivityManager.TYPE_WIFI) {
            onWifiConnectivityChanged();
        }
    }
}
 
Example 5
Project: ucar-weex-core   File: WXCompatModule.java   View Source Code Vote up 7 votes
@Override
public void onReceive(Context context, Intent intent) {
  String action = intent.getAction();
  switch (action) {
    case WXModule.ACTION_ACTIVITY_RESULT:
      int requestCode = intent.getIntExtra(WXModule.REQUEST_CODE, -1);
      int resultCode = intent.getIntExtra(WXModule.RESULT_CODE, Activity.RESULT_OK);
      mWXCompatModule.onActivityResult(requestCode, resultCode, intent);
      break;
    case WXModule.ACTION_REQUEST_PERMISSIONS_RESULT:
      requestCode = intent.getIntExtra(WXModule.REQUEST_CODE, -1);
      String[] permissions = intent.getStringArrayExtra(WXModule.PERMISSIONS);
      int[] grantResults = intent.getIntArrayExtra(WXModule.GRANT_RESULTS);
      mWXCompatModule.onRequestPermissionsResult(requestCode, permissions, grantResults);
      break;
  }
}
 
Example 6
Project: ProgressManager   File: a.java   View Source Code Vote up 6 votes
private void dispatchRequestPermissionsResultToFragment(int requestCode, Intent data,
                                                        Fragment fragment) {
    // If the package installer crashed we may have not data - best effort.
    String[] permissions = (data != null) ? data.getStringArrayExtra(
            PackageManager.EXTRA_REQUEST_PERMISSIONS_NAMES) : new String[0];
    final int[] grantResults = (data != null) ? data.getIntArrayExtra(
            PackageManager.EXTRA_REQUEST_PERMISSIONS_RESULTS) : new int[0];
    fragment.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
 
Example 7
Project: smartkey   File: IntentValueGetter.java   View Source Code Vote up 6 votes
/**
 * Get a value from an intent by a giving class and key.
 * @param intent
 *  the source intent
 * @param key
 *  the key of the value
 * @param clz
 *  the class of the value
 * @return
 *  the value from the source intent
 */
public static Object getValue(Intent intent, String key, Class<?> clz) {
    Object value = null;
    // Cause it is not an easy job to handle inheritance in apt, it is a lot easier to put the code in the Android environment.
    if(Bundle.class.isAssignableFrom(clz)) {
        // bundle implements parcelable, so it should place before parcelable.
        value = intent.getBundleExtra(key);
    } else if(Parcelable.class.isAssignableFrom(clz)) {
        value = intent.getParcelableExtra(key);
    } else if(Parcelable[].class.isAssignableFrom(clz)) {
        value = intent.getParcelableArrayExtra(key);
    } else if(boolean[].class.isAssignableFrom(clz)) {
        value = intent.getBooleanArrayExtra(key);
    } else if(byte[].class.isAssignableFrom(clz)) {
        value = intent.getByteArrayExtra(key);
    } else if(short[].class.isAssignableFrom(clz)) {
        value = intent.getShortArrayExtra(key);
    } else if(char[].class.isAssignableFrom(clz)) {
        value = intent.getCharArrayExtra(key);
    } else if(int[].class.isAssignableFrom(clz)) {
        value = intent.getIntArrayExtra(key);
    } else if(long[].class.isAssignableFrom(clz)) {
        value = intent.getLongArrayExtra(key);
    } else if(float[].class.isAssignableFrom(clz)) {
        value = intent.getFloatArrayExtra(key);
    } else if(double[].class.isAssignableFrom(clz)) {
        value = intent.getDoubleArrayExtra(key);
    } else if(String[].class.isAssignableFrom(clz)) {
        value = intent.getStringArrayExtra(key);
    } else if(CharSequence[].class.isAssignableFrom(clz)) {
        value = intent.getCharSequenceArrayExtra(key);
    } else if(Serializable.class.isAssignableFrom(clz)) {
        // some of the above are assignable for serializable, so serializable should be in the last place.
        value = intent.getSerializableExtra(key);
    } else {
        throw new RuntimeException(clz + " is not compatible with intent (key=" + key + ")");
    }

    return value;
}
 
Example 8
Project: GitHub   File: TopMenuWindow.java   View Source Code Vote up 6 votes
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);
	}
 
Example 9
Project: keepass2android   File: QRCodeEncoder.java   View Source Code Vote up 6 votes
private void encodeFromTextExtras(Intent intent) throws WriterException {
  // Notice: Google Maps shares both URL and details in one text, bummer!
  String theContents = ContactEncoder.trim(intent.getStringExtra(Intent.EXTRA_TEXT));
  if (theContents == null) {
    theContents = ContactEncoder.trim(intent.getStringExtra("android.intent.extra.HTML_TEXT"));
    // Intent.EXTRA_HTML_TEXT
    if (theContents == null) {
      theContents = ContactEncoder.trim(intent.getStringExtra(Intent.EXTRA_SUBJECT));
      if (theContents == null) {
        String[] emails = intent.getStringArrayExtra(Intent.EXTRA_EMAIL);
        if (emails != null) {
          theContents = ContactEncoder.trim(emails[0]);
        } else {
          theContents = "?";
        }
      }
    }
  }

  // Trim text to avoid URL breaking.
  if (theContents == null || theContents.isEmpty()) {
    throw new WriterException("Empty EXTRA_TEXT");
  }
  contents = theContents;
  // We only do QR code.
  format = BarcodeFormat.QR_CODE;
  if (intent.hasExtra(Intent.EXTRA_SUBJECT)) {
    displayContents = intent.getStringExtra(Intent.EXTRA_SUBJECT);
  } else if (intent.hasExtra(Intent.EXTRA_TITLE)) {
    displayContents = intent.getStringExtra(Intent.EXTRA_TITLE);
  } else {
    displayContents = contents;
  }
  title = activity.getString(R.string.contents_text);
}
 
Example 10
Project: KTalk   File: GroupDetailActivity.java   View Source Code Vote up 6 votes
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode == RESULT_OK) {
        // 获取返回的准备邀请的群成员信息
        final String[] memberses = data.getStringArrayExtra("members");

        Model.getInstance().getGlobalThreadPool().execute(new Runnable() {
            @Override
            public void run() {
                try {
                    // 去环信服务器,发送邀请信息
                    EMClient.getInstance().groupManager().addUsersToGroup(mGroup.getGroupId(), memberses);

                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            Toast.makeText(GroupDetailActivity.this, "发送邀请成功", Toast.LENGTH_SHORT).show();
                        }
                    });
                } catch (final HyphenateException e) {
                    e.printStackTrace();

                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            Toast.makeText(GroupDetailActivity.this, "发送邀请失败" + e.toString(), Toast.LENGTH_SHORT).show();
                        }
                    });
                }
            }
        });
    }
}
 
Example 11
Project: gnirehtet   File: GnirehtetControlReceiver.java   View Source Code Vote up 6 votes
private static VpnConfiguration createConfig(Intent intent) {
    String[] dnsServers = intent.getStringArrayExtra(EXTRA_DNS_SERVERS);
    if (dnsServers == null) {
        dnsServers = new String[0];
    }
    return new VpnConfiguration(Net.toInetAddresses(dnsServers));
}
 
Example 12
Project: ProgressManager   File: a.java   View Source Code Vote up 6 votes
private void dispatchRequestPermissionsResult(int requestCode, Intent data) {
    mHasCurrentPermissionsRequest = false;
    // If the package installer crashed we may have not data - best effort.
    String[] permissions = (data != null) ? data.getStringArrayExtra(
            PackageManager.EXTRA_REQUEST_PERMISSIONS_NAMES) : new String[0];
    final int[] grantResults = (data != null) ? data.getIntArrayExtra(
            PackageManager.EXTRA_REQUEST_PERMISSIONS_RESULTS) : new int[0];
    onRequestPermissionsResult(requestCode, permissions, grantResults);
}
 
Example 13
Project: ProgressManager   File: a.java   View Source Code Vote up 6 votes
private void dispatchRequestPermissionsResultToFragment(int requestCode, Intent data,
                                                        Fragment fragment) {
    // If the package installer crashed we may have not data - best effort.
    String[] permissions = (data != null) ? data.getStringArrayExtra(
            PackageManager.EXTRA_REQUEST_PERMISSIONS_NAMES) : new String[0];
    final int[] grantResults = (data != null) ? data.getIntArrayExtra(
            PackageManager.EXTRA_REQUEST_PERMISSIONS_RESULTS) : new int[0];
    fragment.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
 
Example 14
Project: ProgressManager   File: a.java   View Source Code Vote up 6 votes
private void dispatchRequestPermissionsResultToFragment(int requestCode, Intent data,
                                                        Fragment fragment) {
    // If the package installer crashed we may have not data - best effort.
    String[] permissions = (data != null) ? data.getStringArrayExtra(
            PackageManager.EXTRA_REQUEST_PERMISSIONS_NAMES) : new String[0];
    final int[] grantResults = (data != null) ? data.getIntArrayExtra(
            PackageManager.EXTRA_REQUEST_PERMISSIONS_RESULTS) : new int[0];
    fragment.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
 
Example 15
Project: ProgressManager   File: a.java   View Source Code Vote up 6 votes
private void dispatchRequestPermissionsResult(int requestCode, Intent data) {
    mHasCurrentPermissionsRequest = false;
    // If the package installer crashed we may have not data - best effort.
    String[] permissions = (data != null) ? data.getStringArrayExtra(
            PackageManager.EXTRA_REQUEST_PERMISSIONS_NAMES) : new String[0];
    final int[] grantResults = (data != null) ? data.getIntArrayExtra(
            PackageManager.EXTRA_REQUEST_PERMISSIONS_RESULTS) : new int[0];
    onRequestPermissionsResult(requestCode, permissions, grantResults);
}
 
Example 16
Project: LucaHome-MediaServer   File: MenuListUpdater.java   View Source Code Vote up 6 votes
@Override
public void onReceive(Context context, Intent intent) {
    _logger.Debug("_updateReceiver onReceive");
    String[] menuStringArray = intent.getStringArrayExtra(Bundles.MENU);

    if (menuStringArray != null) {
        SerializableList<MenuDto> menu = JsonDataToMenuConverter.GetList(menuStringArray);
        if (menu != null) {
            _broadcastController.SendSerializableBroadcast(Broadcasts.MENU, Bundles.MENU, menu);
        } else {
            Toasty.error(_context, "Failed to convert menu from string array!", Toast.LENGTH_LONG).show();
        }
    }
}
 
Example 17
Project: ProgressManager   File: a.java   View Source Code Vote up 6 votes
private void dispatchRequestPermissionsResultToFragment(int requestCode, Intent data,
                                                        Fragment fragment) {
    // If the package installer crashed we may have not data - best effort.
    String[] permissions = (data != null) ? data.getStringArrayExtra(
            PackageManager.EXTRA_REQUEST_PERMISSIONS_NAMES) : new String[0];
    final int[] grantResults = (data != null) ? data.getIntArrayExtra(
            PackageManager.EXTRA_REQUEST_PERMISSIONS_RESULTS) : new int[0];
    fragment.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
 
Example 18
Project: ProgressManager   File: a.java   View Source Code Vote up 6 votes
private void dispatchRequestPermissionsResultToFragment(int requestCode, Intent data,
                                                        Fragment fragment) {
    // If the package installer crashed we may have not data - best effort.
    String[] permissions = (data != null) ? data.getStringArrayExtra(
            PackageManager.EXTRA_REQUEST_PERMISSIONS_NAMES) : new String[0];
    final int[] grantResults = (data != null) ? data.getIntArrayExtra(
            PackageManager.EXTRA_REQUEST_PERMISSIONS_RESULTS) : new int[0];
    fragment.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
 
Example 19
Project: Android-Practice   File: AppPermissionHandlerActivity.java   View Source Code Vote up 5 votes
private void handleIntent(Intent intent) {
    String[] permissions = intent.getStringArrayExtra(PERMISSION_STRINGS);
    ActivityCompat.requestPermissions(this, permissions, AppPermissionHelper.REQUEST_CODE);
}
 
Example 20
Project: RxPermission   File: ShadowActivity.java   View Source Code Vote up 5 votes
private void handleIntent(final Intent intent) {
  final String[] permissions = intent.getStringArrayExtra(ARG_PERMISSIONS);
  shouldShowRequestPermissionRationale = rationales(permissions);

  requestPermissions(permissions, REQUEST_CODE);
}