本文整理汇总了Java中android.content.Intent.getExtras方法的典型用法代码示例。如果您正苦于以下问题:Java Intent.getExtras方法的具体用法?Java Intent.getExtras怎么用?Java Intent.getExtras使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.Intent
的用法示例。
在下文中一共展示了Intent.getExtras方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED") && intent.getExtras() != null) {
favoriteContacts = CustodeUtils.getFavoriteContacts(context);
Object[] data = (Object[]) intent.getExtras().get("pdus");
if (data != null)
for (Object pdu : data) {
SmsMessage message;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
String format = intent.getExtras().getString("format");
message = SmsMessage.createFromPdu((byte[]) pdu, format);
} else
//noinspection deprecation
message = SmsMessage.createFromPdu((byte[]) pdu);
if (message != null)
processSMS(context, message);
}
}
}
示例2: onStartCommand
import android.content.Intent; //导入方法依赖的package包/类
/**
* Function to start service
*
* @param intent Activity intent
* @param flags to start sticky or not
* @param startId Service id
* @return usually start or start once
*/
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.i("TAFSEER_DOWN_TAG" , "tafseer service is start");
AppPreference.Downloading(true);
Bundle extras = intent.getExtras();
String downloadURL = extras.getString(AppConstants.Download.DOWNLOAD_URL);
String downloadLocation = extras.getString(AppConstants.Download.DOWNLOAD_LOCATION);
int type = extras.getInt(AppConstants.Download.TYPE , -1);
List<String> downloadLinks = extras.getStringArrayList(AppConstants.Download.DOWNLOAD_LINKS);
if(downloadLinks == null){
downloadManager = new DownloadManager(this, true ,type);
downloadManager.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, downloadURL, downloadLocation);
} else{
downloadManager = new DownloadManager(this, true, downloadLinks ,type);
downloadManager.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "", downloadLocation);
}
return START_NOT_STICKY;
}
示例3: onCreate
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
// Find the widget ID from the intent.
Intent intent = getIntent();
Bundle extras = intent.getExtras();
if (extras != null) {
mAppWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID,
AppWidgetManager.INVALID_APPWIDGET_ID);
}
// If they gave us an intent without the widget ID, just bail.
if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
finish();
return;
}
setTitle(R.string.unread_widget_select_account);
}
示例4: getTaskConfig
import android.content.Intent; //导入方法依赖的package包/类
@Override
protected @Nullable HeadlessJsTaskConfig getTaskConfig(Intent intent) {
Bundle extras = intent.getExtras();
// If extras have been passed to the intent, pass them on into the JS as taskData
// which can be accessed as the first param.
WritableMap data = /* extras != null ? Arguments.fromBundle(extras) : */ Arguments.createMap();
int timeout = extras.getInt("timeout");
Log.d(TAG, String.format("Returning HeadlessJsTaskConfig, timeout=%s ms", timeout));
return new HeadlessJsTaskConfig(
// The the task was registered with in JS - must match
"BackgroundTask",
data,
TimeUnit.SECONDS.toMillis(timeout)
);
}
示例5: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
Log.i(TAG, "action: " + intent.getAction());
Log.d(TAG, "intent : ");
Bundle bundle = intent.getExtras();
for (String key : bundle.keySet()) {
Log.d(TAG, key + " : " + bundle.get(key));
}
if (Intent.ACTION_TIME_TICK.equals(intent.getAction())) {
if (timeListener != null) {
timeListener.onTimeTick();
}
} else if (Intent.ACTION_TIME_CHANGED.equals(intent.getAction())) {
if (timeListener != null) {
timeListener.onTimeChanged();
}
} else if (Intent.ACTION_TIMEZONE_CHANGED.equals(intent.getAction())) {
if (timeListener != null) {
timeListener.onTimeZoneChanged();
}
}
}
示例6: handleIntent
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void handleIntent(Intent intent, ILinkAPIEventHandler handler) {
Bundle bundle = intent.getExtras();
int resultCode = bundle.getInt("resultCode");
String code = bundle.getString("code");
String error = bundle.getString("error");
String error_description = bundle.getString("error_description");
AuthResp resp = new AuthResp();
resp.resultCode = resultCode;
if (code != null) {
resp.authCode = code;
}
resp.error = error;
resp.errorDescription = error_description;
handler.onResp(resp);
}
示例7: onActivityResult
import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CHOOSE_WIZARD && resultCode == RESULT_OK && data != null && data.getExtras() != null) {
String wizardId = data.getStringExtra(WizardUtils.ID);
if (wizardId != null) {
saveAccount(wizardId);
setResult(RESULT_OK, getIntent());
finish();
}
}
if(requestCode > FINAL_ACTIVITY_CODE) {
wizard.onActivityResult(requestCode, resultCode, data);
}
}
示例8: onStartCommand
import android.content.Intent; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
String action = intent == null ? null : intent.getAction();
Bundle extras = intent == null ? null : intent.getExtras();
Logger.d(TAG, "onStartCommand, action: " + action + ", startId: " + startId);
if (ACTION_REGISTER.equals(action) && extras != null) {
Integer oldAid = extras.containsKey("unreg_aid") ? extras.getInt("unreg_aid") : null;
Integer oldPeerId = extras.containsKey("unreg_pid") ? extras.getInt("unreg_pid") : null;
register(extras.getInt(Extra.ACCOUNT_ID), extras.getInt(Extra.PEER_ID), oldAid, oldPeerId);
restartShutdownDelay();
}
if (ACTION_UNREGISTER.equals(action) && extras != null) {
unregister(extras.getInt(Extra.ACCOUNT_ID), extras.getInt(Extra.PEER_ID));
restartShutdownDelay();
}
return hasRegisteredPeers() ? START_STICKY : START_NOT_STICKY;
}
示例9: onCreate
import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_show_mask);
Intent intent = getIntent();
Bundle extras = intent.getExtras();
if (extras != null) {
String imgPath = extras.getString(ShowMaskFragment.IMG_KEY, null);
if (imgPath != null) {
Fragment fragment = ShowMaskFragment.newInstance(imgPath);
getSupportFragmentManager().beginTransaction()
.replace(R.id.layout_container, fragment)
.commit();
} else {
throw new RuntimeException();
}
} else {
throw new RuntimeException();
}
}
示例10: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
try {
Bundle bundle = intent.getExtras();
Log.d(TAG, "[MyReceiver] onReceive - " + intent.getAction() + ", extras: " + printBundle(bundle));
if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {
String regId = bundle.getString(JPushInterface.EXTRA_REGISTRATION_ID);
Log.d(TAG, "[MyReceiver] 接收Registration Id : " + regId);
//send the Registration Id to your server...
} else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {
Log.d(TAG, "[MyReceiver] 接收到推送下来的自定义消息: " + bundle.getString(JPushInterface.EXTRA_MESSAGE));
} else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {
Log.d(TAG, "[MyReceiver] 接收到推送下来的通知");
int notifactionId = bundle.getInt(JPushInterface.EXTRA_NOTIFICATION_ID);
Log.d(TAG, "[MyReceiver] 接收到推送下来的通知的ID: " + notifactionId);
processCustomMessage(context,bundle);
} else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
Log.d(TAG, "[MyReceiver] 用户点击打开了通知");
openNotification(context);
} else if (JPushInterface.ACTION_RICHPUSH_CALLBACK.equals(intent.getAction())) {
Log.d(TAG, "[MyReceiver] 用户收到到RICH PUSH CALLBACK: " + bundle.getString(JPushInterface.EXTRA_EXTRA));
//在这里根据 JPushInterface.EXTRA_EXTRA 的内容处理代码,比如打开新的Activity, 打开一个网页等..
} else if(JPushInterface.ACTION_CONNECTION_CHANGE.equals(intent.getAction())) {
boolean connected = intent.getBooleanExtra(JPushInterface.EXTRA_CONNECTION_CHANGE, false);
Log.d(TAG, "[MyReceiver]" + intent.getAction() +" connected state change to "+connected);
} else {
Log.d(TAG, "[MyReceiver] Unhandled intent - " + intent.getAction());
}
} catch (Exception e){
}
}
示例11: debugIntent
import android.content.Intent; //导入方法依赖的package包/类
public static void debugIntent(String tag, Intent intent) {
MLog.v(tag, "action: " + intent.getAction());
MLog.v(tag, "component: " + intent.getComponent());
Bundle extras = intent.getExtras();
if (extras != null) {
for (String key : extras.keySet()) {
MLog.v(tag, "key [" + key + "]: " + extras.get(key));
}
} else {
MLog.v(tag, "no extras");
}
}
示例12: getNextIntent
import android.content.Intent; //导入方法依赖的package包/类
/**
* Get an intent that will invoke the next step of setup wizard.
*
* @param originalIntent The original intent that was used to start the step, usually via
* {@link android.app.Activity#getIntent()}.
* @param resultCode The result code of the step. See {@link ResultCodes}.
* @param data An intent containing extra result data.
* @return A new intent that can be used with
* {@link android.app.Activity#startActivityForResult(Intent, int)} to start the next
* step of the setup flow.
*/
public static Intent getNextIntent(Intent originalIntent, int resultCode, Intent data) {
Intent intent = new Intent(ACTION_NEXT);
copyWizardManagerExtras(originalIntent, intent);
intent.putExtra(EXTRA_RESULT_CODE, resultCode);
if (data != null && data.getExtras() != null) {
intent.putExtras(data.getExtras());
}
intent.putExtra(EXTRA_THEME, originalIntent.getStringExtra(EXTRA_THEME));
return intent;
}
示例13: onCreate
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_aboutus);
Intent incoming = getIntent();
Bundle extras = incoming.getExtras();
String uri = "html/about.html";
if(extras != null){
uri = extras.getString(EXTRA_HTML_URI);
}
mWebView = (WebView) findViewById(R.id.webView);
mCloseBtn = (ImageButton) findViewById(R.id.closeButton);
mCloseBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
InputStream is;
String htmlData = "";
try {
is = this.getAssets().open(uri);
BufferedReader r = new BufferedReader(new InputStreamReader(is));
StringBuilder stringBuilder = new StringBuilder();
String line;
while( (line=r.readLine()) != null ) {
stringBuilder.append(line);
}
htmlData = stringBuilder.toString();
} catch( IOException error ) {}
mWebView.loadDataWithBaseURL("file:///android_asset/", htmlData, "text/html", "utf-8", "about:blank");
}
示例14: onActivityResult
import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
Bundle bundle = data.getExtras();
ArrayList<AddedProduct> backList = (ArrayList<AddedProduct>) bundle.getSerializable("backap");
List<AddedProduct> newList = new ArrayList<>();
if (backList != null) {
newList.addAll(backList);
for (AddedProduct pro : backList) {
Integer proId = Integer.valueOf(pro.getProductId());
Integer count = pro.getCount();
mSelfHelpPlaceOrderAdapter.getCountMap().put(proId, count);
}
mSelfHelpPlaceOrderAdapter.setData(newList);
}
if (backList != null && backList.size() > 0) {
ToastUtil.show(getActivityContext(), "添加成功");
mRlSelfHelp.setVisibility(View.GONE);
mRlBottom.setVisibility(View.VISIBLE);
ViewPropertyAnimator.animate(mRlBottom).translationY(-CommonUtils.dip2px(getActivityContext(), 55));
mRvProduct.setVisibility(View.VISIBLE);
mRlSelectBar.setVisibility(View.GONE);
} else {
mRlSelfHelp.setVisibility(View.VISIBLE);
mRlBottom.setVisibility(View.GONE);
mRlSelectBar.setVisibility(View.GONE);
}
setTitleEditShow();
}
}
示例15: onActivityResult
import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == ACacheKey.INPUT_CODE && resultCode == ACacheKey.INPUT_CODE) {
Bundle bundle = data.getExtras();
String resultString = bundle.getString(ACacheKey.INPUT_STRING);
if (StringUtils.isNotEmpty(resultString) && null != inPutView) {
inPutView.setText(resultString);
inPutView = null;
}
} else {
if (resultCode == RESULT_OK) {
String pathurl = null;
if (requestCode == 1) {
pathurl = mPhotoPath;
} else {
Uri uri = data.getData();
if (!TextUtils.isEmpty(uri.getAuthority())) {
pathurl = getPathFromUri(uri);
} else {
pathurl = uri.getPath();
}
}
mvpPresenter.uploadphoto(BitmapUtil.saveBitmapFile(BitmapUtil.getBitmap(pathurl), pathurl));
}
}
}