本文整理了Java中android.content.Intent.getDataString()
方法的一些代码示例,展示了Intent.getDataString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Intent.getDataString()
方法的具体详情如下:
包路径:android.content.Intent
类名称:Intent
方法名:getDataString
暂无
代码示例来源:origin: facebook/facebook-android-sdk
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent(this, CustomTabMainActivity.class);
intent.setAction(CUSTOM_TAB_REDIRECT_ACTION);
intent.putExtra(CustomTabMainActivity.EXTRA_URL, getIntent().getDataString());
// these flags will open CustomTabMainActivity from the back stack as well as closing this
// activity and the custom tab opened by CustomTabMainActivity.
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivityForResult(intent, CUSTOM_TAB_REDIRECT_REQUEST_CODE);
}
代码示例来源:origin: smuyyh/BookReader
@Override
public void initDatas() {
mFilePath = Uri.decode(getIntent().getDataString().replace("file://", ""));
mFileName = mFilePath.substring(mFilePath.lastIndexOf("/") + 1, mFilePath.lastIndexOf("."));
}
代码示例来源:origin: smuyyh/BookReader
@Override
public void initToolBar() {
String filePath = Uri.decode(getIntent().getDataString().replace("file://", ""));
String fileName = filePath.substring(filePath.lastIndexOf("/") + 1, filePath.lastIndexOf("."));
mCommonToolbar.setTitle(fileName);
mCommonToolbar.setNavigationIcon(R.drawable.ab_back);
}
代码示例来源:origin: smuyyh/BookReader
@Override
public void initToolBar() {
chmFilePath = Uri.decode(getIntent().getDataString().replace("file://", ""));
chmFileName = chmFilePath.substring(chmFilePath.lastIndexOf("/") + 1, chmFilePath.lastIndexOf("."));
mCommonToolbar.setTitle(chmFileName);
mCommonToolbar.setNavigationIcon(R.drawable.ab_back);
}
代码示例来源:origin: robolectric/robolectric
.newInstance(
0 /*resultCode*/,
intent.getDataString(),
intent.getExtras(),
0 /* type */,
.newInstance(
0 /*resultCode*/,
intent.getDataString(),
intent.getExtras(),
0 /* type */,
return new BroadcastReceiver.PendingResult(
0 /*resultCode*/,
intent.getDataString(),
intent.getExtras(),
0 /* type */,
代码示例来源:origin: smuyyh/BookReader
@Override
public void initDatas() {
if (Intent.ACTION_VIEW.equals(getIntent().getAction())) {
String filePath = Uri.decode(getIntent().getDataString().replace("file://", ""));
PDFViewPager pdfViewPager = new PDFViewPager(this, filePath);
llPdfRoot.addView(pdfViewPager);
}
}
代码示例来源:origin: robolectric/robolectric
@Test
public void setUri_shouldReturnUriString() throws Exception {
Intent intent = new Intent();
intent.setData(Uri.parse("http://foo"));
assertThat(intent.getDataString()).isEqualTo("http://foo");
}
代码示例来源:origin: facebook/facebook-android-sdk
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_CANCELED) {
// We weren't able to open CustomTabMainActivity from the back stack. Send a broadcast
// instead.
Intent broadcast = new Intent(CUSTOM_TAB_REDIRECT_ACTION);
broadcast.putExtra(CustomTabMainActivity.EXTRA_URL, getIntent().getDataString());
LocalBroadcastManager.getInstance(this).sendBroadcast(broadcast);
// Wait for the custom tab to be removed from the back stack before finishing.
closeReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
CustomTabActivity.this.finish();
}
};
LocalBroadcastManager.getInstance(this).registerReceiver(
closeReceiver,
new IntentFilter(CustomTabActivity.DESTROY_ACTION)
);
}
}
代码示例来源:origin: robolectric/robolectric
@Test
public void setUri_shouldReturnNullUriString() throws Exception {
Intent intent = new Intent();
assertThat(intent.getDataString()).isNull();
}
代码示例来源:origin: JackyAndroid/AndroidTVLauncher
String packageName = intent.getDataString();
List<ResolveInfo> list = Tools.findActivitiesForPackage(context, packageName);
ResolveInfo info = list.get(0);
String receiverName = intent.getDataString();
receiverName = receiverName.substring(8);
AppModel appBean;
代码示例来源:origin: smuyyh/BookReader
String filePath = Uri.decode(getIntent().getDataString().replace("file://", ""));
String fileName;
if (filePath.lastIndexOf(".") > filePath.lastIndexOf("/")) {
代码示例来源:origin: Justson/AgentWeb
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;
}
代码示例来源:origin: meituan/WMRouter
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_webview);
mWebView = findViewById(R.id.webview);
mProgressBar = findViewById(R.id.progressBar);
mWebView.setWebViewClient(new DemoWebViewClient());
mWebView.setWebChromeClient(new DemoChromeClient());
Intent intent = getIntent();
String url = intent.getDataString();
if (TextUtils.isEmpty(url)) {
finish();
return;
}
mWebView.loadUrl(url);
}
代码示例来源:origin: ukanth/afwall
@Override
public void onReceive(final Context context, final Intent intent) {
Uri inputUri = Uri.parse(intent.getDataString());
代码示例来源:origin: TakWolf/CNode-Material-Design
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!Navigator.openStandardLink(this, getIntent().getDataString())) {
ToastUtils.with(this).show(R.string.invalid_link);
}
finish();
}
代码示例来源:origin: delight-im/Android-AdvancedWebView
if (intent.getDataString() != null) {
dataUris = new Uri[] { Uri.parse(intent.getDataString()) };
代码示例来源:origin: WangDaYeeeeee/Mysplash
private void showErrorInformation(Intent intent) {
Toast.makeText(
this,
"Error - Browser Action Uri\n" + intent.getDataString(),
Toast.LENGTH_LONG).show();
}
}
代码示例来源:origin: stackoverflow.com
public class TestReciver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.d("TestReciver",intent.getAction()+"\n"
+intent.getDataString()+"\n"
+"UID: "+intent.getIntExtra(Intent.EXTRA_UID,0)+"\n"
+"DATA_REMOVED: "+intent.getBooleanExtra(Intent.EXTRA_DATA_REMOVED, false)+"\n"
+"REPLACING: "+intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)
);
}
}
代码示例来源:origin: Coinomi/coinomi-android
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent(this, WalletActivity.class);
intent.putExtra(Constants.ARG_URI, getIntent().getDataString());
startActivity(intent);
finish();
}
}
代码示例来源:origin: openwalletGH/openwallet-android
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent(this, WalletActivity.class);
intent.putExtra(Constants.ARG_URI, getIntent().getDataString());
startActivity(intent);
finish();
}
}
内容来源于网络,如有侵权,请联系作者删除!