本文整理汇总了Java中android.content.Intent.getDataString方法的典型用法代码示例。如果您正苦于以下问题:Java Intent.getDataString方法的具体用法?Java Intent.getDataString怎么用?Java Intent.getDataString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.Intent
的用法示例。
在下文中一共展示了Intent.getDataString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onActivityResultAboveL
import android.content.Intent; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void onActivityResultAboveL(int requestCode, int resultCode, Intent intent) {
if (requestCode != FILECHOOSER_RESULTCODE || mUploadCallbackAboveL == null)
return;
Uri[] results = null;
if (resultCode == Activity.RESULT_OK) {
if (intent != null) {
String dataString = intent.getDataString();
ClipData clipData = intent.getClipData();
if (clipData != null) {
results = new Uri[clipData.getItemCount()];
for (int i = 0; i < clipData.getItemCount(); i++) {
ClipData.Item item = clipData.getItemAt(i);
results[i] = item.getUri();
}
}
if (dataString != null)
results = new Uri[]{Uri.parse(dataString)};
}
}
mUploadCallbackAboveL.onReceiveValue(results);
mUploadCallbackAboveL = null;
}
示例2: processData
import android.content.Intent; //导入方法依赖的package包/类
private Uri[] processData(Intent data) {
Uri[] datas = null;
if (data == null) {
return datas;
}
String target = data.getDataString();
if (!TextUtils.isEmpty(target)) {
return datas = new Uri[]{Uri.parse(target)};
}
ClipData mClipData = data.getClipData();
if (mClipData != null && mClipData.getItemCount() > 0) {
datas = new Uri[mClipData.getItemCount()];
for (int i = 0; i < mClipData.getItemCount(); i++) {
ClipData.Item mItem = mClipData.getItemAt(i);
datas[i] = mItem.getUri();
}
}
return datas;
}
示例3: onActivityResult
import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode==REQUEST_CODE){
if(resultCode==RESULT_OK){
findViewById(R.id.log_in)
.animate()
.scaleX(0)
.scaleY(0)
.setDuration(300)
.start();
String string=data.getDataString();
String code= Uri.parse(string).getQueryParameter("code");
SoundCloudAuth.create(Config.CLIENT_ID,Config.CLIENT_SECRET_ID)
.addRedirectUri(Config.REDIRECT_URI)
.tokenWithAuthCode(code)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(this::saveToken);
}
}
}
示例4: getUrlFromIntent
import android.content.Intent; //导入方法依赖的package包/类
/**
* Retrieve the URL from the Intent, which may be in multiple locations.
* @param intent Intent to examine.
* @return URL from the Intent, or null if a valid URL couldn't be found.
*/
public static String getUrlFromIntent(Intent intent) {
if (intent == null) return null;
String url = getUrlFromVoiceSearchResult(intent);
if (url == null) url = ActivityDelegate.getInitialUrlForDocument(intent);
if (url == null) url = getUrlForCustomTab(intent);
if (url == null) url = intent.getDataString();
if (url == null) return null;
url = url.trim();
if (isGoogleChromeScheme(url)) {
url = getUrlFromGoogleChromeSchemeUrl(url);
}
return TextUtils.isEmpty(url) ? null : url;
}
示例5: startService
import android.content.Intent; //导入方法依赖的package包/类
private void startService() {
final Intent intent = super.getIntent();
if (intent == null || intent.getBooleanExtra(Intent.EXTRA_INTENT, false)) {
serviceAction(ServiceAction.SHOW);
return;
}
String uri = intent.getDataString();
if (uri != null && (uri.contains(LinkType.NORMAL) || uri.contains(LinkType.SHORT))) {
startService(uri);
return;
}
uri = intent.getStringExtra(Intent.EXTRA_TEXT);
if (!TextUtils.isEmpty(uri)) {
if (!uri.startsWith("http") && (uri.contains(LinkType.NORMAL) || uri.contains(LinkType.SHORT))) {
uri = uri.substring(uri.indexOf("http"));
}
startService(uri);
return;
}
super.finish();
}
示例6: onActivityResultAboveL
import android.content.Intent; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void onActivityResultAboveL(int requestCode, int resultCode, Intent intent)
{
if (requestCode != FILE_CHOOSER_RESULT_CODE || uploadMessageAboveL == null)
return;
Uri[] results = null;
if (resultCode == Activity.RESULT_OK)
{
if (intent != null)
{
String dataString = intent.getDataString();
ClipData clipData = intent.getClipData();
if (clipData != null)
{
results = new Uri[clipData.getItemCount()];
for (int i = 0; i < clipData.getItemCount(); i++)
{
ClipData.Item item = clipData.getItemAt(i);
results[i] = item.getUri();
}
}
if (dataString != null)
results = new Uri[]{Uri.parse(dataString)};
}
}
uploadMessageAboveL.onReceiveValue(results);
uploadMessageAboveL = null;
}
示例7: onReceive
import android.content.Intent; //导入方法依赖的package包/类
public static void onReceive(Context context, Intent intent) {
if (intent != null) {
String intentAction = intent.getAction();
final String sPackageName = intent.getDataString();
if (TextUtils.isEmpty(sPackageName)) {
return;
}
final String pkgName = sPackageName.substring(sPackageName.indexOf(':') + 1);
if (TextUtils.isEmpty(pkgName)) {
return;
}
if (Intent.ACTION_PACKAGE_ADDED.equals(intentAction) || Intent.ACTION_PACKAGE_REPLACED.equals(intentAction) || Intent.ACTION_PACKAGE_REMOVED.equals(intentAction)) {
boolean contains = isContainsKey(pkgName);
logPrint("onReceive pkgName=" + pkgName + " isContainsKey=" + contains);
if (contains) {
updateInstallState(pkgName, SmartInstallItem.installComplete);
}
}
}
}
示例8: handleNewIntent
import android.content.Intent; //导入方法依赖的package包/类
public void handleNewIntent(Intent intent) {
String url = null;
if (intent != null) {
url = intent.getDataString();
}
int num = 0;
int type=0;
if (intent != null && intent.getExtras() != null) {
num = intent.getExtras().getInt(getPackageName() + ".Origin");
//type=intent.getExtras().getInt("type");
//ToastUtil.showMessage("this type "+type);
}
if (num == 1) {
LightningView lv=getCurrentWebView();
lv.loadUrl(url);
} else if (url != null) {
if (url.startsWith(Constants.FILE)) {
Utils.showToast(this, getResources().getString(R.string.message_blocked_local));
url = null;
}
newTab(url, true);
mIsNewIntent = true;
}
}
示例9: onPostCreate
import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void onPostCreate(@Nullable Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
Intent intent = getIntent();
if(intent.getAction() != null && intent.getAction().equals(Intent.ACTION_VIEW)) {
String data = intent.getDataString();
switch (data) {
case "anime":
shortcut = R.id.nav_anime;
break;
case "manga":
shortcut = R.id.nav_manga;
break;
case "trending":
shortcut = R.id.nav_trending;
break;
case "reviews":
shortcut = R.id.nav_reviews;
break;
}
}
if(status != 0)
try {
if(requesting)
requesting = false;
app_status.setText(getString(status));
} catch(Exception e){
e.printStackTrace();
}
intiApplication();
}
示例10: onActivityResult
import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
if (Build.VERSION.SDK_INT >= 21) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
getWindow().setStatusBarColor(getResources().getColor(R.color.colorPrimary));
Uri[] results = null;
if (resultCode == Activity.RESULT_OK) {
if (requestCode == asw_file_req) {
if (null == asw_file_path) {
return;
}
if (intent == null) {
if (asw_cam_message != null) {
results = new Uri[]{Uri.parse(asw_cam_message)};
}
} else {
String dataString = intent.getDataString();
if (dataString != null) {
results = new Uri[]{ Uri.parse(dataString) };
}
}
}
}
asw_file_path.onReceiveValue(results);
asw_file_path = null;
} else {
if (requestCode == asw_file_req) {
if (null == asw_file_message) return;
Uri result = intent == null || resultCode != RESULT_OK ? null : intent.getData();
asw_file_message.onReceiveValue(result);
asw_file_message = null;
}
}
}
示例11: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
String dataString = intent.getDataString();
if (PACKAGE_REPLACED.equals(action)) {
Log.d("PackageReplaceReceiver", "Received " + dataString);
if ("package:ru.orangesoftware.financisto".equals(dataString)) {
Log.d("PackageReplaceReceiver", "Re-scheduling all transactions");
requestScheduleAll(context);
requestScheduleAutoBackup(context);
requestScheduleAutoSync(context);
}
}
}
示例12: onNewIntent
import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void onNewIntent(final Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
final String feedUrl = intent.getDataString();
if (!TextUtils.isEmpty(feedUrl)) {
newFeedSubscriptionIntentReceived(feedUrl, false);
}
}
示例13: onHandleIntent
import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent, @Nullable MasterSecret masterSecret) {
if (!TelephonyManager.ACTION_RESPOND_VIA_MESSAGE.equals(intent.getAction())) {
Log.w(TAG, "Received unknown intent: " + intent.getAction());
return;
}
if (masterSecret == null) {
Log.w(TAG, "Got quick response request when locked...");
Toast.makeText(this, R.string.QuickResponseService_quick_response_unavailable_when_Signal_is_locked, Toast.LENGTH_LONG).show();
return;
}
try {
Rfc5724Uri uri = new Rfc5724Uri(intent.getDataString());
String content = intent.getStringExtra(Intent.EXTRA_TEXT);
String numbers = uri.getPath();
if(numbers.contains("%")){
numbers = URLDecoder.decode(numbers);
}
Recipients recipients = RecipientFactory.getRecipientsFromString(this, numbers, false);
Optional<RecipientsPreferences> preferences = DatabaseFactory.getRecipientPreferenceDatabase(this).getRecipientsPreferences(recipients.getIds());
int subscriptionId = preferences.isPresent() ? preferences.get().getDefaultSubscriptionId().or(-1) : -1;
long expiresIn = preferences.isPresent() ? preferences.get().getExpireMessages() * 1000 : 0;
if (!TextUtils.isEmpty(content)) {
if (recipients.isSingleRecipient()) {
MessageSender.send(this, masterSecret, new OutgoingTextMessage(recipients, content, expiresIn, subscriptionId), -1, false, null);
} else {
MessageSender.send(this, masterSecret, new OutgoingMediaMessage(recipients, new SlideDeck(), content, System.currentTimeMillis(),
subscriptionId, expiresIn, ThreadDatabase.DistributionTypes.DEFAULT), -1, false, null);
}
}
} catch (URISyntaxException e) {
Toast.makeText(this, R.string.QuickResponseService_problem_sending_message, Toast.LENGTH_LONG).show();
Log.w(TAG, e);
}
}
示例14: onActivityResult
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
if (requestCode == FILECHOOSER_RESULTCODE) {
if (null == this.mUploadMessage) {
return;
}
Uri result = null;
try {
if (resultCode != RESULT_OK) {
result = null;
} else {
// retrieve from the private variable if the intent is null
result = data == null ? mCapturedImageURI : data.getData();
}
} catch (Exception e) {
}
mUploadMessage.onReceiveValue(result);
mUploadMessage = null;
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (requestCode != FILECHOOSER_RESULTCODE || mFilePathCallback == null) {
super.onActivityResult(requestCode, resultCode, data);
return;
}
Uri[] results = null;
if (resultCode == Activity.RESULT_OK) {
if (data == null) {
if (mCameraPhotoPath != null) {
results = new Uri[]{Uri.parse(mCameraPhotoPath)};
}
} else {
String dataString = data.getDataString();
if (dataString != null) {
results = new Uri[]{Uri.parse(dataString)};
}
}
}
mFilePathCallback.onReceiveValue(results);
mFilePathCallback = null;
}
}
示例15: onActivityResult
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
if (requestCode == FILECHOOSER_RESULTCODE) {
if (null == this.mUploadMessage) {
return;
}
Uri result = null;
try {
if (resultCode != RESULT_OK) {
result = null;
} else {
// retrieve from the private variable if the intent is null
result = data == null ? mCapturedImageURI : data.getData();
}
} catch (Exception e) {
}
mUploadMessage.onReceiveValue(result);
mUploadMessage = null;
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (requestCode != FILECHOOSER_RESULTCODE || mFilePathCallback == null) {
super.onActivityResult(requestCode, resultCode, data);
return;
}
Uri[] results = null;
if (resultCode == Activity.RESULT_OK) {
if (data == null) {
if (mCameraPhotoPath != null) {
results = new Uri[]{Uri.parse(mCameraPhotoPath)};
}
} else {
String dataString = data.getDataString();
if (dataString != null) {
results = new Uri[]{Uri.parse(dataString)};
}
}
}
mFilePathCallback.onReceiveValue(results);
mFilePathCallback = null;
}
}