本文整理汇总了Java中android.content.Intent.getIntExtra方法的典型用法代码示例。如果您正苦于以下问题:Java Intent.getIntExtra方法的具体用法?Java Intent.getIntExtra怎么用?Java Intent.getIntExtra使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.Intent
的用法示例。
在下文中一共展示了Intent.getIntExtra方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent = getIntent();
int button = intent.getIntExtra(BUTTON_KEY, 0);
if(button > 0) {
((TextView)findViewById(R.id.textview)).setText("Button " + button + " is pressed!");
}
//Ask permission
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.canDrawOverlays(this)) {
Intent permissionIntent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
Uri.parse("package:" + getPackageName()));
startActivityForResult(permissionIntent, CODE_DRAW_OVER_OTHER_APP_PERMISSION);
}
}
示例2: d
import android.content.Intent; //导入方法依赖的package包/类
private void d(Intent intent) {
if (intent != null) {
String stringExtra = intent.getStringExtra("error");
Throwable th = new Throwable(stringExtra + " (" + intent.getIntExtra("error_code", -1) + SocializeConstants.OP_CLOSE_PAREN);
if (this.c != null) {
this.c.onFailed(th);
}
} else if (this.c != null) {
this.c.onCancel();
}
}
示例3: onNewIntent
import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
int requestCode = intent.getIntExtra("pay_success",0);
if(requestCode == REQUEST_CODE_PAY_SUCCESS){
selectOrderFragment();
}
}
示例4: onCreate
import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// get activity title from intent
Intent intent = this.getIntent();
// set activity title
if (intent.hasExtra(EXTRA_INFOSHEET_TITLE)) {
this.setTitle(intent.getStringExtra(EXTRA_INFOSHEET_TITLE));
}
// set activity view
if (intent.hasExtra(EXTRA_INFOSHEET_CONTENT) && intent.getIntExtra(EXTRA_INFOSHEET_CONTENT, -1) == INFOSHEET_CONTENT_ABOUT) {
setContentView(R.layout.fragment_infosheet_about);
} else if (intent.hasExtra(EXTRA_INFOSHEET_CONTENT) && intent.getIntExtra(EXTRA_INFOSHEET_CONTENT, -1) == INFOSHEET_CONTENT_HOWTO) {
setContentView(R.layout.fragment_infosheet_howto);
}
}
示例5: onStartCommand
import android.content.Intent; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (!startDownload && intent != null){
startDownload = true;
downloadUrl = intent.getStringExtra(URL);
icoResId = intent.getIntExtra(ICO_RES_ID, DEFAULT_RES_ID);
icoSmallResId = intent.getIntExtra(ICO_SMALL_RES_ID, DEFAULT_RES_ID);
storeDir = intent.getStringExtra(STORE_DIR);
updateProgress = intent.getIntExtra(UPDATE_PROGRESS, UPDATE_NUMBER_SIZE);
downloadNotificationFlag = intent.getIntExtra(DOWNLOAD_NOTIFICATION_FLAG, 0);
downloadErrorNotificationFlag = intent.getIntExtra(DOWNLOAD_ERROR_NOTIFICATION_FLAG, 0);
downloadSuccessNotificationFlag = intent.getIntExtra(DOWNLOAD_SUCCESS_NOTIFICATION_FLAG, 0);
isSendBroadcast = intent.getBooleanExtra(IS_SEND_BROADCAST, false);
// if (DEBUG){
LogUtil.e(TAG, "downloadUrl: " + downloadUrl);
LogUtil.e(TAG, "icoResId: " + icoResId);
LogUtil.e(TAG, "icoSmallResId: " + icoSmallResId);
LogUtil.e(TAG, "storeDir: " + storeDir);
LogUtil.e(TAG, "updateProgress: " + updateProgress);
LogUtil.e(TAG, "downloadNotificationFlag: " + downloadNotificationFlag);
LogUtil.e(TAG, "downloadErrorNotificationFlag: " + downloadErrorNotificationFlag);
LogUtil.e(TAG, "downloadSuccessNotificationFlag: " + downloadSuccessNotificationFlag);
LogUtil.e(TAG, "isSendBroadcast: " + isSendBroadcast);
// }
notifyId = startId;
buildNotification();
buildBroadcast();
downloadApkTask = new DownloadApk(this);
downloadApkTask.execute(downloadUrl);
}
return super.onStartCommand(intent, flags, startId);
}
示例6: performBondStateChangeAction
import android.content.Intent; //导入方法依赖的package包/类
private void performBondStateChangeAction(Intent intent) {
final int state = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.ERROR);
final int prevState = intent.getIntExtra(BluetoothDevice.EXTRA_PREVIOUS_BOND_STATE, BluetoothDevice.ERROR);
if (state == BluetoothDevice.BOND_BONDED && prevState == BluetoothDevice.BOND_BONDING) {
showToast(mContext.getString(R.string.device_paired));
connectToZephyrDevice();
} else if (state == BluetoothDevice.BOND_NONE) {
showToast(mContext.getString(R.string.device_pairing_failure));
}
}
示例7: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
Integer tmpWakeLockId = CoreReceiver.getWakeLock(context);
try {
Timber.i("CoreReceiver.onReceive %s", intent);
if (CoreReceiver.WAKE_LOCK_RELEASE.equals(intent.getAction())) {
Integer wakeLockId = intent.getIntExtra(WAKE_LOCK_ID, -1);
if (wakeLockId != -1) {
Timber.v("CoreReceiver Release wakeLock %d", wakeLockId);
CoreReceiver.releaseWakeLock(wakeLockId);
}
} else {
tmpWakeLockId = receive(context, intent, tmpWakeLockId);
}
} finally {
CoreReceiver.releaseWakeLock(tmpWakeLockId);
}
}
示例8: onActivityResult
import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
switch (resultCode) {
case 1:
int netState = data.getIntExtra("netState", 0);
switch (netState) {
case 0:
autoPlayVideoSettingsText.setText("仅wifi");
break;
case 1:
autoPlayVideoSettingsText.setText("移动蜂窝和wifi");
break;
case 2:
autoPlayVideoSettingsText.setText("从不");
break;
default:
break;
}
break;
default:
break;
}
}
示例9: onActivityResult
import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (data != null) {
switch (resultCode) {
case TimePickerActivity.FOR_TIME_RESULT:
int v = data.getIntExtra(TimePickerActivity.TIME, -1);
if (v > -1) {
dt = new SimpleDate(v);
mAreTime.setText(dt.toString());
}
break;
case DatePickerActivity.FOR_DATE_RESULT:
dd.setTimeInMillis(data.getLongExtra(DatePickerActivity.DATE, System.currentTimeMillis()));
mAreDate.setText(sdf.format(new Date(dd.getTimeInMillis())));
break;
case RemindFrSettingActivity.FOR_FR:
fr = data.getIntExtra(RemindFrSettingActivity.TYPE, 0);
mAreFr.setText(AssistUtils.translateRemindFrequency(fr, dd));
break;
}
}
super.onActivityResult(requestCode, resultCode, data);
}
示例10: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onReceive(Context arg0, Intent intent)
{
String action=intent.getAction();
if(action.equals(Intent.ACTION_BATTERY_CHANGED))
{
//Toast.makeText(arg0, "test", 5).show();
currentBatteryLevel = intent.getIntExtra("level" , 0);
scale = intent.getIntExtra("scale", 100);
health = intent.getIntExtra("health" , 0);
plug = intent.getIntExtra("plugged", 0);
status = intent.getIntExtra("status", 0);
temperature = intent.getIntExtra("temperature", 0);
voltage = intent.getIntExtra("voltage", 0);
technology = intent.getIntExtra("technology", 0);
}
}
示例11: onActivityReenter
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onActivityReenter(int resultCode, Intent data) {
postponeEnterTransition();
// Start the postponed transition when the recycler view is ready to be drawn.
grid.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
grid.getViewTreeObserver().removeOnPreDrawListener(this);
startPostponedEnterTransition();
return true;
}
});
if (data == null) {
return;
}
final int selectedItem = data.getIntExtra(IntentUtil.SELECTED_ITEM_POSITION, 0);
grid.scrollToPosition(selectedItem);
PhotoViewHolder holder = (PhotoViewHolder) grid.
findViewHolderForAdapterPosition(selectedItem);
if (holder == null) {
Log.w(TAG, "onActivityReenter: Holder is null, remapping cancelled.");
return;
}
DetailSharedElementEnterCallback callback =
new DetailSharedElementEnterCallback(getIntent());
callback.setView(holder.itemView);
setExitSharedElementCallback(callback);
}
示例12: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
if (Intent.ACTION_BATTERY_CHANGED.equals(intent.getAction())) {
// 0 indicates that we're on battery
boolean onBatteryNow = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1) <= 0;
if (onBatteryNow) {
InactivityTimer.this.onActivity();
} else {
InactivityTimer.this.cancel();
}
}
}
示例13: initUIandEvent
import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void initUIandEvent() {
event().addEventHandler(this);
Intent i = getIntent();
int cRole = i.getIntExtra(ConstantApp.ACTION_KEY_CROLE, 0);
if (cRole == 0) {
throw new RuntimeException("Should not reach here");
}
String roomName = i.getStringExtra(ConstantApp.ACTION_KEY_ROOM_NAME);
doConfigEngine(cRole);
mGridVideoViewContainer = (GridVideoViewContainer) findViewById(R.id.grid_video_view_container);
mGridVideoViewContainer.setItemEventHandler(new VideoViewEventListener() {
@Override
public void onItemDoubleClick(View v, Object item) {
log.debug("onItemDoubleClick " + v + " " + item);
if (mUidsList.size() < 2) {
return;
}
if (mViewType == VIEW_TYPE_DEFAULT)
switchToSmallVideoView(((VideoStatusData) item).mUid);
else
switchToDefaultVideoView();
}
});
ImageView button1 = (ImageView) findViewById(R.id.btn_1);
ImageView button2 = (ImageView) findViewById(R.id.btn_2);
ImageView button3 = (ImageView) findViewById(R.id.btn_3);
if (isBroadcaster(cRole)) {
SurfaceView surfaceV = RtcEngine.CreateRendererView(getApplicationContext());
rtcEngine().setupLocalVideo(new VideoCanvas(surfaceV, VideoCanvas.RENDER_MODE_HIDDEN, 0));
surfaceV.setZOrderOnTop(true);
surfaceV.setZOrderMediaOverlay(true);
mUidsList.put(0, surfaceV); // get first surface view
mGridVideoViewContainer.initViewContainer(getApplicationContext(), 0, mUidsList); // first is now full view
worker().preview(true, surfaceV, 0);
broadcasterUI(button1, button2, button3);
} else {
audienceUI(button1, button2, button3);
}
worker().joinChannel(roomName, config().mUid);
TextView textRoomName = (TextView) findViewById(R.id.room_name);
textRoomName.setText(roomName);
}
示例14: onHandleIntent
import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
userDataSource = new UserDataSource(getApplicationContext());
userItems = new ArrayList<>();
profileDataSource = new ProfileDataSource(this);
profileItem = new ProfileItem();
if (intent != null) {
int intentType = intent.getIntExtra("intent_type", 0);
switch (intentType) {
case httpIntentLoadUsers: {
loadGithubUsers();
}
break;
case httpIntentLoadProfile: {
profileUrl = intent.getStringExtra("profile_url");
loadGithubProfile();
}
break;
}
}
}
示例15: getBatteryLevel
import android.content.Intent; //导入方法依赖的package包/类
private float getBatteryLevel() {
Intent batteryStatus = registerReceiver(null,
new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
int batteryLevel = -1;
int batteryScale = 1;
if (batteryStatus != null) {
batteryLevel = batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, batteryLevel);
batteryScale = batteryStatus.getIntExtra(BatteryManager.EXTRA_SCALE, batteryScale);
}
return batteryLevel / (float) batteryScale * 100;
}