本文整理汇总了Java中android.content.Intent.getAction方法的典型用法代码示例。如果您正苦于以下问题:Java Intent.getAction方法的具体用法?Java Intent.getAction怎么用?Java Intent.getAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.Intent
的用法示例。
在下文中一共展示了Intent.getAction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
// When discovery finds a device
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
// Get the BluetoothDevice object from the Intent
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
// If it's already paired, skip it, because it's been listed already
if (device.getBondState() != BluetoothDevice.BOND_BONDED) {
mNewDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress());
}
// When discovery is finished, change the Activity title
} else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
setProgressBarIndeterminateVisibility(false);
setTitle(R.string.select_device);
if (mNewDevicesArrayAdapter.getCount() == 0) {
String noDevices = getResources().getText(R.string.none_found).toString();
mNewDevicesArrayAdapter.add(noDevices);
}
}
}
示例2: onNewIntent
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onNewIntent(Intent intent)
{
String action = intent.getAction();
// Log.i("!intent! ", action);
Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
byte[] id = tag.getId();
String serialNumber = bytesToHex(id);
WritableMap idData = Arguments.createMap();
idData.putString("id", serialNumber);
sendEvent(this.reactContext, "NFCCardID", idData);
}
示例3: onCreate
import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
Intent intent = getIntent();
String action = intent.getAction();
if (Intent.ACTION_VIEW.equals(action)) {
Uri uri = intent.getData();
if (uri != null) {
String host = uri.getHost();
String scheme = uri.getScheme();
String name = uri.getQueryParameter("name");
ToastUtil.showLong("参数 name:" + name);
Logger.i("host=" + host + " ; scheme=" + scheme + " ; name=" + name);
}
}
}
示例4: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
Intent newIntent = new Intent("change-playback-action-event");
switch (action) {
case ACTION_PAUSE:
newIntent.putExtra("action", PlaybackAction.PAUSE);
LocalBroadcastManager.getInstance(context).sendBroadcast(newIntent);
break;
case ACTION_PLAY:
newIntent.putExtra("action", PlaybackAction.PLAY);
LocalBroadcastManager.getInstance(context).sendBroadcast(newIntent);
break;
case ACTION_NEXT:
newIntent.putExtra("action", PlaybackAction.SKIP_TO_NEXT);
LocalBroadcastManager.getInstance(context).sendBroadcast(newIntent);
break;
case ACTION_PREV:
newIntent.putExtra("action", PlaybackAction.SKIP_TO_PREVIOUS);
LocalBroadcastManager.getInstance(context).sendBroadcast(newIntent);
break;
default:
break;
}
}
开发者ID:AllThatSeries,项目名称:react-native-streaming-audio-player,代码行数:27,代码来源:MediaNotificationManager.java
示例5: onReceive
import android.content.Intent; //导入方法依赖的package包/类
public void onReceive(Context context, Intent intent) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context
.getApplicationContext());
if (!prefs.getBoolean("enable_autostart", false)) {
Log.d("RepWifi", "autostart is false");
return;
}
Log.d("RepWifi", "Autostart is true");
String a = intent.getAction();
if (a.equals(Intent.ACTION_BOOT_COMPLETED) || a.equals(Intent.ACTION_REBOOT)) {
launchRepWifiMainActivity(context, RequestCode.NONE);
}
}
示例6: onServiceConnected
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onServiceConnected(ComponentName componentName, IBinder service) {
MusicService.MusicServiceBinder musicServiceBinder = (MusicService.MusicServiceBinder) service;
musicService = musicServiceBinder.getService();
mServiceBounded = true;
// ahora que tenemos el servicio vinculado, miramos si nos están enviando una llamada desde
// la notificación mediante una acción de pausa
Intent receivedIntent = getIntent();
if (receivedIntent != null && receivedIntent.getAction() != null && receivedIntent.getAction().equals(Utils.ACTION_PAUSE)) {
// venimos de la acción de pause de notificación
if (mServiceBounded) {
musicService.pauseMusic();
btnPause.setVisibility(View.INVISIBLE);
btnPlay.setVisibility(View.VISIBLE);
}
}
}
示例7: 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;
}
}
示例8: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onReceive(final Context context, Intent intent) {
String action = intent.getAction();
switch (action) {
case DownloadManager.ACTION_NOTIFICATION_CLICKED:
openDownload(context, intent);
break;
case DownloadNotificationService.ACTION_DOWNLOAD_RESUME:
case DownloadNotificationService.ACTION_DOWNLOAD_CANCEL:
case DownloadNotificationService.ACTION_DOWNLOAD_PAUSE:
case DownloadNotificationService.ACTION_DOWNLOAD_OPEN:
performDownloadOperation(context, intent);
break;
default:
break;
}
}
示例9: handleIntent
import android.content.Intent; //导入方法依赖的package包/类
private void handleIntent() {
Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
if (intent == null) {
return;
}
if (type == null) {
return;
}
//getStringExtra() may return null
if (Intent.ACTION_SEND.equals(action) && type.equals("text/plain")) {
mTextToProcess = intent.getStringExtra(Intent.EXTRA_TEXT);
mTargetWord = intent.getStringExtra(Constant.INTENT_ANKIHELPER_TARGET_WORD);
//mFbReaderBookmarkId = intent.getStringExtra(Constant.INTENT_ANKIHELPER_FBREADER_BOOKMARK_ID);
String noteEditedByUser = intent.getStringExtra(Constant.INTENT_ANKIHELPER_NOTE);
String updateId = intent.getStringExtra(Constant.INTENT_ANKIHELPER_NOTE_ID);
}
if(Intent.ACTION_PROCESS_TEXT.equals(action)&&type.equals("text/plain"))
{
mTextToProcess = intent.getStringExtra(Intent.EXTRA_PROCESS_TEXT);
}
if(mTextToProcess ==null)
{
return;
}
populateWordSelectBox();
}
示例10: onReceive
import android.content.Intent; //导入方法依赖的package包/类
public void onReceive(Context context, Intent intent) {
String s = intent.getAction();
String st1 = getResources().getString(R.string.Network_error);
if (s.equals(SDKInitializer.SDK_BROADTCAST_ACTION_STRING_PERMISSION_CHECK_ERROR)) {
String st2 = getResources().getString(R.string.please_check);
Toast.makeText(instance, st2, Toast.LENGTH_SHORT).show();
} else if (s.equals(SDKInitializer.SDK_BROADCAST_ACTION_STRING_NETWORK_ERROR)) {
Toast.makeText(instance, st1, Toast.LENGTH_SHORT).show();
}
}
示例11: onBroadcastReceived
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onBroadcastReceived(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(GravityBoxSettings.ACTION_PREF_DATA_TRAFFIC_CHANGED)) {
if (intent.hasExtra(GravityBoxSettings.EXTRA_DT_MODE)) {
return;
}
if (intent.hasExtra(GravityBoxSettings.EXTRA_DT_POSITION)) {
mPosition = intent.getIntExtra(GravityBoxSettings.EXTRA_DT_POSITION,
GravityBoxSettings.DT_POSITION_AUTO);
}
if (intent.hasExtra(GravityBoxSettings.EXTRA_DT_SIZE)) {
mSize = intent.getIntExtra(GravityBoxSettings.EXTRA_DT_SIZE, 14);
}
if (intent.hasExtra(GravityBoxSettings.EXTRA_DT_DISPLAY_MODE)) {
mDisplayMode = DisplayMode.valueOf(intent.getStringExtra(
GravityBoxSettings.EXTRA_DT_DISPLAY_MODE));
}
if (intent.hasExtra(GravityBoxSettings.EXTRA_DT_ACTIVE_MOBILE_ONLY)) {
mShowOnlyForMobileData = intent.getBooleanExtra(
GravityBoxSettings.EXTRA_DT_ACTIVE_MOBILE_ONLY, false);
}
if (intent.hasExtra(GravityBoxSettings.EXTRA_DT_LOCKSCREEN)) {
mAllowInLockscreen = intent.getBooleanExtra(
GravityBoxSettings.EXTRA_DT_LOCKSCREEN, false);
}
onPreferenceChanged(intent);
updateState();
} else if (action.equals(Intent.ACTION_SCREEN_ON) ||
action.equals(Intent.ACTION_SCREEN_OFF)) {
mIsScreenOn = action.equals(Intent.ACTION_SCREEN_ON);
updateState();
}
}
示例12: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (BluetoothLeService.ACTION_GATT_CONNECTED.equals(action)) {
ULog.i("ACTION_GATT_CONNECTED!!!");
mConnectionState = BluetoothLeService.ACTION_GATT_CONNECTED;
mProgressBar.setVisibility(View.INVISIBLE);
if (!TextUtils.isEmpty(mDeviceAddress)) {
Contants.bluetoothAddress(mDeviceAddress);
if (!TextUtils.isEmpty(mDeviceName)) {
Contants.bluetoothName(mDeviceName);
} else {
Contants.bluetoothName(getString(R.string.device_unknown));
}
}
UToast.showMsg(getString(R.string.connected_success) + "\n" + Contants.bluetoothName());
} else if (BluetoothLeService.ACTION_GATT_DISCONNECTED.equals(action)) {
ULog.i("ACTION_GATT_DISCONNECTED!!!");
UToast.showMsg(R.string.disconnected_error);
mConnectionState = BluetoothLeService.ACTION_GATT_DISCONNECTED;
mProgressBar.setVisibility(View.INVISIBLE);
} else if (BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED.equals(action)) {
mBluetoothLeService.getSupportedGattServices();
} else if (BluetoothLeService.ACTION_DATA_AVAILABLE.equals(action)) {
final byte[] data = intent.getByteArrayExtra(BluetoothLeService.EXTRA_DATA);
mTextViewReceive.append(UString.getStringFromByteArray(data));
ULog.i("Get string : " + new String(data));
if (data != null && data.length > 0) {
final StringBuilder stringBuilder = new StringBuilder(data.length);
for (byte byteChar : data) {
stringBuilder.append(String.format("%02X ", byteChar));
}
ULog.i("Get string(ASCII) : " + stringBuilder.toString());
}
}
}
示例13: onReceive
import android.content.Intent; //导入方法依赖的package包/类
/**
* Receives and processes a button pressed intent or state change.
*
* @param context
* @param intent Indicates the pressed button.
*/
@Override
public void onReceive(final Context context, Intent intent) {
String act = intent.getAction();
if (AppWidgetManager.ACTION_APPWIDGET_DELETED.equals(act)) {
final int appWidgetId = intent.getExtras().getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
if (appWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID) {
this.onDeleted(context, new int[] { appWidgetId });
}
}
super.onReceive(context, intent);
}
示例14: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(GravityBoxSettings.ACTION_LOCKSCREEN_SETTINGS_CHANGED)) {
mPrefs.reload();
if (DEBUG) log("Settings reloaded");
}
}
示例15: onReceive
import android.content.Intent; //导入方法依赖的package包/类
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
// Discovery has found a device.
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
// Get the BluetoothDevice object and its info from the Intent.
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
int bondState = device.getBondState();
String foundName = device.getName();
String foundAddress = device.getAddress(); // MAC address
Timber.d("Discovery has found a device: %d/%s/%s", bondState, foundName, foundAddress);
if (isSelectedDevice(foundAddress)) {
createBond(device);
} else {
Timber.d("Unknown device, skipping bond attempt.");
}
} else if (BluetoothDevice.ACTION_BOND_STATE_CHANGED.equals(action)) {
int state = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, -1);
switch (state) {
case BluetoothDevice.BOND_NONE:
Timber.d("The remote device is not bonded.");
break;
case BluetoothDevice.BOND_BONDING:
Timber.d("Bonding is in progress with the remote device.");
break;
case BluetoothDevice.BOND_BONDED:
Timber.d("The remote device is bonded.");
break;
default:
Timber.d("Unknown remote device bonding state.");
break;
}
}
}