Java Code Examples for android.content.Intent.getAction()

The following are Jave code examples for showing how to use getAction() of the android.content.Intent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: iconsole-android   File: DeviceListActivity.java   View Source Code Vote up 10 votes
@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);
        }
    }
}
 
Example 2
Project: nfc-react-native-simple   File: NfcReactNativeSimpleModule.java   View Source Code Vote up 8 votes
@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);

    }
 
Example 3
Project: cardinalsSample   File: SplashActivity.java   View Source Code Vote up 8 votes
@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);
        }
    }
}
 
Example 4
Project: react-native-streaming-audio-player   File: MediaNotificationManager.java   View Source Code Vote up 7 votes
@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;
    }
}
 
Example 5
Project: RepWifiApp   File: RepWifiIntentReceiver.java   View Source Code Vote up 7 votes
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);
        }

    }
 
Example 6
Project: Android-2017   File: MainActivity.java   View Source Code Vote up 7 votes
@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);
        }
    }


}
 
Example 7
Project: ucar-weex-core   File: WXCompatModule.java   View Source Code Vote up 7 votes
@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;
  }
}
 
Example 8
Project: chromium-for-android-56-debug-video   File: DownloadBroadcastReceiver.java   View Source Code Vote up 7 votes
@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;
    }
}
 
Example 9
Project: quiz_helper   File: PopupActivity.java   View Source Code Vote up 6 votes
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();
}
 
Example 10
Project: KTalk   File: EaseBaiduMapActivity.java   View Source Code Vote up 6 votes
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();
	}
}
 
Example 11
Project: GravityBox   File: TrafficMeterAbstract.java   View Source Code Vote up 6 votes
@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();
    }
}
 
Example 12
Project: BluetoothCtrl   File: MainActivity.java   View Source Code Vote up 6 votes
@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());
        }
    }
}
 
Example 13
Project: CSipSimple   File: ShortcutWidgetProvider.java   View Source Code Vote up 6 votes
/**
   * 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);

  }
 
Example 14
Project: GravityBox   File: ModFingerprint.java   View Source Code Vote up 6 votes
@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");
    }
}
 
Example 15
Project: android-robocar   File: Nes30Connection.java   View Source Code Vote up 6 votes
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;
    }
  }
}
 
Example 16
Project: arduator   File: ArduinoCommManagerBt.java   View Source Code Vote up 6 votes
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    if (BluetoothDevice.ACTION_FOUND.equals(action)) {
        // Discovery has found a device. Get the BluetoothDevice
        // object and its info from the Intent.
        BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
        onFind(device);
    }
}
 
Example 17
Project: Camera-Roll-Android-App   File: AlbumActivity.java   View Source Code Vote up 6 votes
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (resultCode) {
        default:
            if (data != null && data.getAction() != null) {
                onNewIntent(data);
            }
            break;
    }
}
 
Example 18
Project: memetastic   File: MemeCreateActivity.java   View Source Code Vote up 5 votes
@SuppressWarnings({"unchecked", "ConstantConditions"})
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (AppSettings.get().isEditorStatusBarHidden()) {
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }
    setContentView(R.layout.memecreate__activity);
    if (AppSettings.get().isEditorStatusBarHidden()) {
        AndroidBug5497Workaround.assistActivity(this);
    }

    // Quit activity if no conf was given
    Intent intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();
    if (!(Intent.ACTION_SEND.equals(action) && type.startsWith("image/")) &&
            (!getIntent().hasExtra(EXTRA_IMAGE_PATH))) {
        finish();
        return;
    }

    // Stop if data is not loaded yet (Try load in onResume, recreate activity in broadcast)
    if (MemeData.isReady()) {
        // Bind Ui
        ButterKnife.bind(this);
        _app = (App) getApplication();

        // Set _toolbar
        setSupportActionBar(_toolbar);
        if (getSupportActionBar() != null) {
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        }
        initMemeSettings(savedInstanceState);
        initMoarControlsContainer();
        initCaptionButtons();
    }
    if (savedInstanceState != null
            && savedInstanceState.containsKey("captionPosition")
            && savedInstanceState.containsKey("captionEditBar")
            && savedInstanceState.containsKey("captionText")) {
        _isBottom = savedInstanceState.getBoolean("captionPosition");
        _editBar.setVisibility(savedInstanceState.getBoolean("captionEditBar") ?
                View.VISIBLE : View.GONE);
        _create_caption.setText(savedInstanceState.getString("captionText"));
    }
}
 
Example 19
Project: GcmForMojo   File: QqNotificationBroadcastReceiver.java   View Source Code Vote up 5 votes
@Override
public void onReceive(Context context, Intent intent) {

    ArrayList<User> currentUserList;
    Map<Integer, Integer> msgCountMap;

  //  MyApplication = (MyApplication) context.getApplicationContext();
    currentUserList = MyApplication.getInstance().getCurrentUserList();
    msgCountMap = MyApplication.getInstance().getMsgCountMap();

    String action = intent.getAction();
    Bundle msgNotifyBundle = intent.getExtras();
    int notifyId = msgNotifyBundle.getInt("notifyId");
    String qqPackgeName=msgNotifyBundle.getString("qqPackgeName");

    if (notifyId != -1) {
        NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.cancel(notifyId);
        for(int    i=0;    i<currentUserList.size();    i++){
            if(currentUserList.get(i).getNotifyId()==notifyId){
                currentUserList.get(i).setMsgCount("0");
                if(CurrentUserActivity.userHandler!=null)
                    new userThread().start();
                break;
            }
        }
    }

    if (action.equals("qq_notification_clicked")) {
        //处理点击事件

            // 通过包名获取要跳转的app,创建intent对象
            Intent intentNewQq = context.getPackageManager().getLaunchIntentForPackage(qqPackgeName);

            if (intentNewQq != null) {
                if (msgCountMap.get(notifyId) != null)
                    msgCountMap.put(notifyId, 0);
                context.startActivity(intentNewQq);
            } else {
                // 没有安装要跳转的app应用进行提醒
                Toast.makeText(context.getApplicationContext(), "未检测到" + qqPackgeName, Toast.LENGTH_LONG).show();
            }

    }

    if (action.equals("qq_notification_cancelled")) {
        //处理滑动清除和点击删除事件
        if(msgCountMap.get(notifyId)!=null)
        msgCountMap.put(notifyId,0);
    }

}
 
Example 20
Project: aos-Video   File: VideoSearchActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Intent intent = getIntent();
    String action = intent != null ? intent.getAction() : null;
    if (Intent.ACTION_VIEW.equals(action)) {
        // this is something we got from the global search bar
        Cursor cursor = null;
        try {
            int videoId = Integer.parseInt(intent.getData().getLastPathSegment());
            SingleVideoLoader loader = new SingleVideoLoader(this, videoId);
            cursor = getContentResolver().query(loader.getUri(), loader.getProjection(), loader.getSelection(), loader.getSelectionArgs(), loader.getSortOrder());
            if (cursor.getCount() > 0) {
                VideoCursorMapper cursorMapper = new VideoCursorMapper();
                cursorMapper.publicBindColumns(cursor);
                cursor.moveToFirst();
                Video video = (Video)cursorMapper.publicBind(cursor);

                Intent activityIntent = new Intent(this, VideoDetailsActivity.class);
                activityIntent.putExtra(VideoDetailsFragment.EXTRA_VIDEO, video);
                startActivity(activityIntent);
            }
        } finally {
            if (cursor != null) {
                cursor.close();
            }
        }
        finish();
        return;
    }

    setContentView(R.layout.androidtv_search_activity);

    Bundle args = new Bundle();
    args.putInt(EXTRA_SEARCH_MODE, getIntent().getIntExtra(EXTRA_SEARCH_MODE, SEARCH_MODE_ALL));

    VideoSearchFragment frag = new VideoSearchFragment();
    frag.setArguments(args);
    getFragmentManager().beginTransaction().add(R.id.video_search_fragment, frag).commit();
}