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

The following are Jave code examples for showing how to use getExtras() 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: custode   File: SmsUpdateReceiver.java   View Source Code Vote up 7 votes
@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);
            }
    }
}
 
Example 2
Project: QuranAndroid   File: DownloadTafseerService.java   View Source Code Vote up 7 votes
/**
 * 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;
}
 
Example 3
Project: q-mail   File: UnreadWidgetConfiguration.java   View Source Code Vote up 7 votes
@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);
}
 
Example 4
Project: react-native-background-task   File: HeadlessTaskService.java   View Source Code Vote up 7 votes
@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)
    );
}
 
Example 5
Project: XinFramework   File: TimeReceiver.java   View Source Code Vote up 7 votes
@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();
        }
    }
}
 
Example 6
Project: linkopensdk-android   File: LinkApiImplV3.java   View Source Code Vote up 7 votes
@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);
}
 
Example 7
Project: CSipSimple   File: BasePrefsWizard.java   View Source Code Vote up 7 votes
@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);
	}
}
 
Example 8
Project: Phoenix-for-VK   File: LongpollService.java   View Source Code Vote up 7 votes
@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;
}
 
Example 9
Project: face-landmark-android   File: ShowMaskActivity.java   View Source Code Vote up 7 votes
@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();
    }
}
 
Example 10
Project: Renrentou   File: JpushReceiver.java   View Source Code Vote up 7 votes
@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){

    }

}
 
Example 11
Project: phonk   File: AndroidUtils.java   View Source Code Vote up 6 votes
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");
    }
}
 
Example 12
Project: SetupWizardLibCompat   File: WizardManagerHelper.java   View Source Code Vote up 6 votes
/**
 * 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;
}
 
Example 13
Project: Tech-Jalsa   File: LocalWebActivity.java   View Source Code Vote up 6 votes
@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");
}
 
Example 14
Project: GongXianSheng   File: SelfHelpPlaceOrderActivity.java   View Source Code Vote up 6 votes
@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();
    }
}
 
Example 15
Project: GCSApp   File: CircleInfoActivity.java   View Source Code Vote up 6 votes
@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));

        }
    }

}
 
Example 16
Project: CommonsLab   File: UploadToCommonsFragment.java   View Source Code Vote up 6 votes
public void onReceive(Context context, Intent intent) {
    Bundle bundle = intent.getExtras();
    int type = bundle.getInt(OpusEvent.EVENT_TYPE, 0);
    switch (type) {
        case OpusEvent.CONVERT_FINISHED:

            break;
        case OpusEvent.CONVERT_FAILED:
            break;
        case OpusEvent.CONVERT_STARTED:
            break;
        case OpusEvent.RECORD_FAILED:
            break;
        case OpusEvent.RECORD_FINISHED:

            break;
        case OpusEvent.RECORD_STARTED:
            break;
        case OpusEvent.RECORD_PROGRESS_UPDATE:
            break;
        case OpusEvent.PLAY_PROGRESS_UPDATE:
            break;
        case OpusEvent.PLAY_GET_AUDIO_TRACK_INFO:
            break;
        case OpusEvent.PLAYING_FAILED:
            break;
        case OpusEvent.PLAYING_FINISHED:
            break;
        case OpusEvent.PLAYING_PAUSED:
            break;
        case OpusEvent.PLAYING_STARTED:
            break;
        default:
            Log.d("OPUS", intent.toString() + "Invalid request,discarded");
            break;
    }
}
 
Example 17
Project: lrs_android   File: JPushReceiver.java   View Source Code Vote up 6 votes
@Override
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    Bundle bundle = intent.getExtras();
    switch (action) {
        case JPUSH_REGISTRATION:
            LogUtil.e(JPUSH_REGISTRATION);
            break;
        case JPUSH_MESSAGE_RECEIVED:
            String message = bundle.getString(JPushInterface.EXTRA_MESSAGE);
            LogUtil.e(JPUSH_MESSAGE_RECEIVED + "\t" + message);
            break;
        case JPUSH_NOTIFICATION_RECEIVED:
            String content = bundle.getString(JPushInterface.EXTRA_ALERT);
            LogUtil.e(JPUSH_NOTIFICATION_RECEIVED + "\t" + content);
            break;
        case JPUSH_NOTIFICATION_OPENED:
            LogUtil.e(JPUSH_NOTIFICATION_OPENED);
            break;
        case JPUSH_NOTIFICATION_CLICK_ACTION:
            LogUtil.e(JPUSH_NOTIFICATION_CLICK_ACTION);
            break;
        case JPUSH_CONNECTION:
            LogUtil.e(JPUSH_CONNECTION);
            break;
    }
}
 
Example 18
Project: xifan   File: DownLoadApkService.java   View Source Code Vote up 6 votes
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Bundle bundle = intent.getExtras();
    if (bundle == null) {
        return START_REDELIVER_INTENT;
    }

    String url = bundle.getString(EXTRA_URL);
    if (!TextUtils.isEmpty(url)) {
        downLoadApk(url);
    }
    //服务被kill,服务将自动重启,并传入最后一个Intent
    return START_REDELIVER_INTENT;
}
 
Example 19
Project: prada   File: SettingReceiver.java   View Source Code Vote up 5 votes
private void doUploadSettingChange(Context context, Intent intent) {
    Log.i(TAG, "doUploadSettingChange");
    Bundle extras = intent.getExtras();
    boolean isAgreeUpload = extras.getBoolean("isAgreeUpload");
    Log.i(TAG, "isAgreeUpload: " + isAgreeUpload);
}
 
Example 20
Project: LucaHome-AndroidApplication   File: SocketActionReceiver.java   View Source Code Vote up 5 votes
@Override
public void onReceive(Context context, Intent intent) {
    Bundle details = intent.getExtras();
    if (details == null) {
        Logger.getInstance().Error(TAG, "Details is null!");
        return;
    }

    String action = details.getString(NotificationController.ACTION);
    if (action == null) {
        Logger.getInstance().Error(TAG, "Action is null!");
        return;
    }

    switch (action) {
        case NotificationController.SOCKET_ALL:
            WirelessSocketService.getInstance().DeactivateAllWirelessSockets();
            break;

        case NotificationController.SOCKET_SINGLE:
            WirelessSocket socket = (WirelessSocket) details.getSerializable(NotificationController.SOCKET_DATA);

            if (socket == null) {
                Logger.getInstance().Error(TAG, "Socket is null!");
                Toasty.error(context, "Socket is null!", Toast.LENGTH_LONG).show();
                return;
            }

            try {
                WirelessSocketService.getInstance().ChangeWirelessSocketState(socket);
            } catch (Exception exception) {
                Logger.getInstance().Error(TAG, exception.getMessage());
            }
            break;

        default:
            Logger.getInstance().Error(TAG, "Action contains errors: " + action);
            Toasty.error(context, "Action contains errors: " + action, Toast.LENGTH_LONG).show();
            break;
    }
}