当前位置: 首页>>代码示例>>Java>>正文


Java Intent.hasExtra方法代码示例

本文整理汇总了Java中android.content.Intent.hasExtra方法的典型用法代码示例。如果您正苦于以下问题:Java Intent.hasExtra方法的具体用法?Java Intent.hasExtra怎么用?Java Intent.hasExtra使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.Intent的用法示例。


在下文中一共展示了Intent.hasExtra方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleIntent

import android.content.Intent; //导入方法依赖的package包/类
private void handleIntent( Intent intent ) {
	if( intent == null || intent.getAction() == null || mCallbacks == null) {
		return;
	}

	String action = intent.getAction();

	if( action.equalsIgnoreCase( ACTION_PLAY ) ) {
		mCallbacks.onPlay();
	} else if( action.equalsIgnoreCase( ACTION_PAUSE ) ) {
		mCallbacks.onPause();
	} else if( action.equalsIgnoreCase( ACTION_FORWARD) ) {
		mCallbacks.onFastForward();
	} else if( action.equalsIgnoreCase( ACTION_REWIND ) ) {
		mCallbacks.onRewind();
	} else if( action.equalsIgnoreCase( ACTION_PREVIOUS ) ) {
		mCallbacks.onSkipToPrevious();
	} else if( action.equalsIgnoreCase( ACTION_NEXT ) ) {
		mCallbacks.onSkipToNext();
	} else if( action.equalsIgnoreCase( ACTION_STOP ) ) {
		mCallbacks.onStop();
	} else if( action.equalsIgnoreCase( ACTION_SEEK ) && intent.hasExtra( VOD_PROGRESS ) ) {
		if (mp != null && mediaSession.isActive()) {
			mp.seekTo(intent.getIntExtra( VOD_PROGRESS, 0 ));
		}
	}
}
 
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:28,代码来源:PlayerService.java

示例2: 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(TransistorKeys.EXTRA_INFOSHEET_TITLE)) {
        this.setTitle(intent.getStringExtra(TransistorKeys.EXTRA_INFOSHEET_TITLE));
    }

    // set activity view
    if (intent.hasExtra(TransistorKeys.EXTRA_INFOSHEET_CONTENT) && intent.getIntExtra(TransistorKeys.EXTRA_INFOSHEET_CONTENT, -1) == TransistorKeys.INFOSHEET_CONTENT_ABOUT) {
        setContentView(R.layout.fragment_infosheet_about);
    } else if (intent.hasExtra(TransistorKeys.EXTRA_INFOSHEET_CONTENT) && intent.getIntExtra(TransistorKeys.EXTRA_INFOSHEET_CONTENT, -1) == TransistorKeys.INFOSHEET_CONTENT_HOWTO) {
        setContentView(R.layout.fragment_infosheet_howto);
    }

}
 
开发者ID:malah-code,项目名称:Open-Quran-Radio,代码行数:21,代码来源:InfosheetActivity.java

示例3: initializeFromIntent

import android.content.Intent; //导入方法依赖的package包/类
/**
 * Convenience method to initialize camera id, decode formats and prompt message from an intent.
 *
 * @param intent the intent, as generated by IntentIntegrator
 */
public void initializeFromIntent(Intent intent) {
    // Scan the formats the intent requested, and return the result to the calling activity.
    Set<BarcodeFormat> decodeFormats = DecodeFormatManager.parseDecodeFormats(intent);
    Map<DecodeHintType, Object> decodeHints = DecodeHintManager.parseDecodeHints(intent);

    CameraSettings settings = new CameraSettings();

    if (intent.hasExtra(Intents.Scan.CAMERA_ID)) {
        int cameraId = intent.getIntExtra(Intents.Scan.CAMERA_ID, -1);
        if (cameraId >= 0) {
            settings.setRequestedCameraId(cameraId);
        }
    }

    // Check to see if the scan should be inverted.
    boolean inverted = intent.getBooleanExtra(Intents.Scan.INVERTED_SCAN, false);

    String characterSet = intent.getStringExtra(Intents.Scan.CHARACTER_SET);

    MultiFormatReader reader = new MultiFormatReader();
    reader.setHints(decodeHints);

    barcodeView.setCameraSettings(settings);
    barcodeView.setDecoderFactory(new DefaultDecoderFactory(decodeFormats, decodeHints, characterSet, inverted));
}
 
开发者ID:yinhaojun,项目名称:ZxingForAndroid,代码行数:31,代码来源:DecoratedBarcodeView.java

示例4: put

import android.content.Intent; //导入方法依赖的package包/类
public static Bundle put(Bundle to, Intent from, String key) {
    if (!(to == null || from == null || TextUtils.empty(key) || !from.hasExtra(key))) {
        Object value = from.getExtras().get(key);
        if (value instanceof Boolean) {
            to.putBoolean(key, ((Boolean) value).booleanValue());
        } else if (value instanceof Byte) {
            to.putByte(key, ((Byte) value).byteValue());
        } else if (value instanceof Character) {
            to.putChar(key, ((Character) value).charValue());
        } else if (value instanceof Short) {
            to.putShort(key, ((Short) value).shortValue());
        } else if (value instanceof Integer) {
            to.putInt(key, ((Integer) value).intValue());
        } else if (value instanceof Long) {
            to.putLong(key, ((Long) value).longValue());
        } else if (value instanceof Float) {
            to.putFloat(key, ((Float) value).floatValue());
        } else if (value instanceof Double) {
            to.putDouble(key, ((Double) value).doubleValue());
        } else if (value instanceof String) {
            to.putString(key, (String) value);
        }
    }
    return to;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:26,代码来源:KVUtils.java

示例5: onReceive

import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
  GoogleCloudMessaging gcm         = GoogleCloudMessaging.getInstance(context);
  String               messageType = gcm.getMessageType(intent);

  if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
    Log.w(TAG, "GCM message...");

    if (!TextSecurePreferences.isPushRegistered(context)) {
      Log.w(TAG, "Not push registered!");
      return;
    }

    String messageData = intent.getStringExtra("message");
    String receiptData = intent.getStringExtra("receipt");

    if      (!TextUtils.isEmpty(messageData)) handleReceivedMessage(context, messageData);
    else if (!TextUtils.isEmpty(receiptData)) handleReceivedMessage(context, receiptData);
    else if (intent.hasExtra("notification")) handleReceivedNotification(context);
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:22,代码来源:GcmBroadcastReceiver.java

示例6: onReceive

import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    if (intent.getAction().equals(GravityBoxSettings.ACTION_PREF_POWER_CHANGED)) {
        if (intent.hasExtra(GravityBoxSettings.EXTRA_POWER_PROXIMITY_WAKE)) {
            toggleWakeUpWithProximityFeature(intent.getBooleanExtra(
                    GravityBoxSettings.EXTRA_POWER_PROXIMITY_WAKE, false));
        }
        if (intent.hasExtra(GravityBoxSettings.EXTRA_POWER_PROXIMITY_WAKE_IGNORE_CALL)) {
            mIgnoreIncomingCall = intent.getBooleanExtra(
                    GravityBoxSettings.EXTRA_POWER_PROXIMITY_WAKE_IGNORE_CALL, false);
        }
    } else if (intent.getAction().equals(GravityBoxSettings.ACTION_PREF_BATTERY_SOUND_CHANGED) &&
            intent.getIntExtra(GravityBoxSettings.EXTRA_BATTERY_SOUND_TYPE, -1) == 
                BatteryInfoManager.SOUND_WIRELESS) {
        updateIsWirelessChargingSoundCustom(intent.getStringExtra(
                GravityBoxSettings.EXTRA_BATTERY_SOUND_URI));
    }
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:19,代码来源:ModPower.java

示例7: onBroadcastReceived

import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onBroadcastReceived(Context context, Intent intent) {
    super.onBroadcastReceived(context, intent);
    if (DEBUG) log(getKey() + ": onBroadcastReceived: " + intent.toString());

    if (intent.getAction().equals(ACTION_PREF_QUICKAPP_CHANGED)) {
        if (intent.hasExtra(GravityBoxSettings.EXTRA_QUICKAPP_DEFAULT)) {
            updateMainApp(intent.getStringExtra(GravityBoxSettings.EXTRA_QUICKAPP_DEFAULT));
        }
        if (intent.hasExtra(GravityBoxSettings.EXTRA_QUICKAPP_SLOT1)) {
            updateSubApp(0, intent.getStringExtra(GravityBoxSettings.EXTRA_QUICKAPP_SLOT1));
        }
        if (intent.hasExtra(GravityBoxSettings.EXTRA_QUICKAPP_SLOT2)) {
            updateSubApp(1, intent.getStringExtra(GravityBoxSettings.EXTRA_QUICKAPP_SLOT2));
        }
        if (intent.hasExtra(GravityBoxSettings.EXTRA_QUICKAPP_SLOT3)) {
            updateSubApp(2, intent.getStringExtra(GravityBoxSettings.EXTRA_QUICKAPP_SLOT3));
        }
        if (intent.hasExtra(GravityBoxSettings.EXTRA_QUICKAPP_SLOT4)) {
            updateSubApp(3, intent.getStringExtra(GravityBoxSettings.EXTRA_QUICKAPP_SLOT4));
        }
    }
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:24,代码来源:QuickAppTile.java

示例8: onBroadcastReceived

import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onBroadcastReceived(Context context, Intent intent) {
    super.onBroadcastReceived(context, intent);

    if (intent.getAction().equals(GravityBoxSettings.ACTION_PREF_QUICKSETTINGS_CHANGED)) {
        if (intent.hasExtra(GravityBoxSettings.EXTRA_QR_QUALITY)) {
            mAudioQuality = intent.getIntExtra(GravityBoxSettings.EXTRA_QR_QUALITY,
                    RecordingService.DEFAULT_SAMPLING_RATE);
        }
        if (intent.hasExtra(GravityBoxSettings.EXTRA_QR_AUTOSTOP)) {
            mAutoStopDelay = intent.getIntExtra(GravityBoxSettings.EXTRA_QR_AUTOSTOP, 1) * 3600000;
        }
    }
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:15,代码来源:QuickRecordTile.java

示例9: showDialogIf

import android.content.Intent; //导入方法依赖的package包/类
private void showDialogIf(Intent intent) {
	if (intent.hasExtra("id")) {
		id = intent.getExtras().getString("id");
		intent.removeExtra("id");
		Bundle args = new Bundle();
		args.putString("id", id);
		JoinGameDialogFragment fragment = new JoinGameDialogFragment();
		fragment.setArguments(args);
		fragment.show(getSupportFragmentManager(), "dialog");
	}
}
 
开发者ID:eduyayo,项目名称:gamesboard,代码行数:12,代码来源:GameListActivity.java

示例10: onStart

import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onStart(Intent intent, int startId) {
    if (DEBUG_LIFECYCLE)
        ApkLogger.get().debug(TAG + " - onStart", null);
    super.onStart(intent, startId);
    if (intent != null && intent.hasExtra(ApkConstant.EXTRA_APK_TARGET_INTENT)) {
        Intent target = intent.getParcelableExtra(ApkConstant.EXTRA_APK_TARGET_INTENT);
        HookService_Manager.onStartService(this, target, startId);
    }
}
 
开发者ID:LiangMaYong,项目名称:android-apkbox,代码行数:11,代码来源:Proxy404Service.java

示例11: initTelephonyReceiver

import android.content.Intent; //导入方法依赖的package包/类
/**
 * Listen for telephony events: RINGING, OFFHOOK and IDLE
 * Send these events to all plugins using
 *      CordovaActivity.onMessage("telephone", "ringing" | "offhook" | "idle")
 */
private void initTelephonyReceiver() {
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
    //final CordovaInterface mycordova = this.cordova;
    this.telephonyReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {

            // If state has changed
            if ((intent != null) && intent.getAction().equals(TelephonyManager.ACTION_PHONE_STATE_CHANGED)) {
                if (intent.hasExtra(TelephonyManager.EXTRA_STATE)) {
                    String extraData = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
                    if (extraData.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
                        LOG.i(TAG, "Telephone RINGING");
                        webView.getPluginManager().postMessage("telephone", "ringing");
                    }
                    else if (extraData.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) {
                        LOG.i(TAG, "Telephone OFFHOOK");
                        webView.getPluginManager().postMessage("telephone", "offhook");
                    }
                    else if (extraData.equals(TelephonyManager.EXTRA_STATE_IDLE)) {
                        LOG.i(TAG, "Telephone IDLE");
                        webView.getPluginManager().postMessage("telephone", "idle");
                    }
                }
            }
        }
    };

    // Register the receiver
    webView.getContext().registerReceiver(this.telephonyReceiver, intentFilter);
}
 
开发者ID:SUTFutureCoder,项目名称:localcloud_fe,代码行数:39,代码来源:CoreAndroid.java

示例12: onActivityResult

import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_CONTACT && resultCode == Activity.RESULT_OK && data != null &&
            (data.hasExtra(ContactPickerActivity.RESULT_GROUP_DATA) ||
                    data.hasExtra(ContactPickerActivity.RESULT_CONTACT_DATA))) {

        List<Contact> mContacts = (List<Contact>) data.getSerializableExtra(ContactPickerActivity.RESULT_CONTACT_DATA);
        populateContactList(mContacts);
    }
}
 
开发者ID:adithya321,项目名称:SOS-The-Healthcare-Companion,代码行数:11,代码来源:HelloActivity.java

示例13: onBroadcastReceived

import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onBroadcastReceived(Context context, Intent intent) {
    if (intent.getAction().equals(GravityBoxSettings.ACTION_PREF_STATUSBAR_COLOR_CHANGED)) {
        if (intent.hasExtra(GravityBoxSettings.EXTRA_SB_ICON_COLOR)) {
            setIconColor(intent.getIntExtra(
                    GravityBoxSettings.EXTRA_SB_ICON_COLOR, getDefaultIconColor()));
        } else if (intent.hasExtra(GravityBoxSettings.EXTRA_SB_ICON_STYLE)) {
            setIconStyle(intent.getIntExtra(GravityBoxSettings.EXTRA_SB_ICON_STYLE, 0));
        } else if (intent.hasExtra(GravityBoxSettings.EXTRA_SB_ICON_COLOR_SECONDARY)) {
            setIconColor(1, intent.getIntExtra(
                    GravityBoxSettings.EXTRA_SB_ICON_COLOR_SECONDARY, 
                    getDefaultIconColor()));
        } else if (intent.hasExtra(GravityBoxSettings.EXTRA_SB_DATA_ACTIVITY_COLOR)) {
            setDataActivityColor(intent.getIntExtra(
                    GravityBoxSettings.EXTRA_SB_DATA_ACTIVITY_COLOR, 
                    mColorInfo.defaultDataActivityColor));
        } else if (intent.hasExtra(GravityBoxSettings.EXTRA_SB_DATA_ACTIVITY_COLOR_SECONDARY)) {
            setDataActivityColor(1, intent.getIntExtra(
                    GravityBoxSettings.EXTRA_SB_DATA_ACTIVITY_COLOR_SECONDARY, 
                    mColorInfo.defaultDataActivityColor));
        } else if (intent.hasExtra(GravityBoxSettings.EXTRA_SB_ICON_COLOR_ENABLE)) {
            setColoringEnabled(intent.getBooleanExtra(
                    GravityBoxSettings.EXTRA_SB_ICON_COLOR_ENABLE, false));
            if (DEBUG) log("Icon colors master switch set to: " + isColoringEnabled());
        } else if (intent.hasExtra(GravityBoxSettings.EXTRA_SB_SIGNAL_COLOR_MODE)) {
            setSignalIconMode(intent.getIntExtra(
                    GravityBoxSettings.EXTRA_SB_SIGNAL_COLOR_MODE,
                    StatusBarIconManager.SI_MODE_STOCK));
        }
    }
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:32,代码来源:StatusBarIconManager.java

示例14: modify

import android.content.Intent; //导入方法依赖的package包/类
public static Intent modify(Activity target, Intent intent) {
    if (!intent.hasExtra(ApkConstant.EXTRA_APK_PATH)
            && target.getIntent().hasExtra(ApkConstant.EXTRA_APK_PATH)) {
        Bundle extras = intent.getExtras();
        if (extras != null) {
            intent.replaceExtras(new Bundle());
            String extras_id = ApkExtras.putExtras(extras);
            intent.putExtra(ApkConstant.EXTRA_APK_EXTRAS, extras_id);
        }
        String apkPath = target.getIntent().getStringExtra(ApkConstant.EXTRA_APK_PATH);
        intent.putExtra(ApkConstant.EXTRA_APK_PATH, apkPath);
        // launch mode
        if (intent.getComponent() != null) {
            try {
                ActivityInfo activityInfo = ApkLoaded.get(target, apkPath).getActivityInfo(intent.getComponent().getClassName());
                String launchModeStr = HookActivity_Component.STANDARD;
                int launchMode = activityInfo.launchMode;
                if (launchMode == ActivityInfo.LAUNCH_SINGLE_INSTANCE) {
                    launchModeStr = HookActivity_Component.SINGLE_INSTANCE;
                } else if (launchMode == ActivityInfo.LAUNCH_SINGLE_TASK) {
                    launchModeStr = HookActivity_Component.SINGLE_TASK;
                } else if (launchMode == ActivityInfo.LAUNCH_SINGLE_TOP) {
                    launchModeStr = HookActivity_Component.SINGLE_TOP;
                }
                intent.putExtra(ApkConstant.EXTRA_APK_LAUNCH_MODE, launchModeStr);
            } catch (Exception e) {
            }
        }
    }
    return HookActivity_Component.modify(intent);
}
 
开发者ID:LiangMaYong,项目名称:android-apkbox,代码行数:32,代码来源:HookActivity_Intent.java

示例15: onNewIntent

import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);

    if (intent.hasExtra(NfcAdapter.EXTRA_TAG)) {
        Toast.makeText(this, "NfcIntent!", Toast.LENGTH_SHORT).show();

        Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
        NdefMessage ndefMessage = createNdefMessage("My string content!");

        writeNdefMessage(tag, ndefMessage);
    }
}
 
开发者ID:tekesan,项目名称:TraiNFCUI,代码行数:14,代码来源:Tap.java


注:本文中的android.content.Intent.hasExtra方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。