本文整理汇总了Java中android.content.Intent.getStringArrayExtra方法的典型用法代码示例。如果您正苦于以下问题:Java Intent.getStringArrayExtra方法的具体用法?Java Intent.getStringArrayExtra怎么用?Java Intent.getStringArrayExtra使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.Intent
的用法示例。
在下文中一共展示了Intent.getStringArrayExtra方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPlayerData
import android.content.Intent; //导入方法依赖的package包/类
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();
}
}
示例2: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@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();
}
}
}
示例3: combineArrayExtra
import android.content.Intent; //导入方法依赖的package包/类
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);
}
示例4: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@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();
}
}
}
示例5: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@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;
}
}
示例6: dispatchRequestPermissionsResultToFragment
import android.content.Intent; //导入方法依赖的package包/类
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);
}
示例7: getValue
import android.content.Intent; //导入方法依赖的package包/类
/**
* 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;
}
示例8: init
import android.content.Intent; //导入方法依赖的package包/类
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);
}
示例9: encodeFromTextExtras
import android.content.Intent; //导入方法依赖的package包/类
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);
}
示例10: onActivityResult
import android.content.Intent; //导入方法依赖的package包/类
@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();
}
});
}
}
});
}
}
示例11: createConfig
import android.content.Intent; //导入方法依赖的package包/类
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));
}
示例12: dispatchRequestPermissionsResult
import android.content.Intent; //导入方法依赖的package包/类
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);
}
示例13: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@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();
}
}
}
示例14: handleIntent
import android.content.Intent; //导入方法依赖的package包/类
private void handleIntent(Intent intent) {
String[] permissions = intent.getStringArrayExtra(PERMISSION_STRINGS);
ActivityCompat.requestPermissions(this, permissions, AppPermissionHelper.REQUEST_CODE);
}
示例15: handleIntent
import android.content.Intent; //导入方法依赖的package包/类
private void handleIntent(final Intent intent) {
final String[] permissions = intent.getStringArrayExtra(ARG_PERMISSIONS);
shouldShowRequestPermissionRationale = rationales(permissions);
requestPermissions(permissions, REQUEST_CODE);
}