本文整理了Java中android.content.Intent.resolveActivityInfo()
方法的一些代码示例,展示了Intent.resolveActivityInfo()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Intent.resolveActivityInfo()
方法的具体详情如下:
包路径:android.content.Intent
类名称:Intent
方法名:resolveActivityInfo
暂无
代码示例来源:origin: robolectric/robolectric
@Test
public void resolveActivityInfo_shouldReturnActivityInfoForExistingActivity() {
Context context = ApplicationProvider.getApplicationContext();
PackageManager packageManager = context.getPackageManager();
Intent intent = new Intent();
intent.setClassName(context, TEST_ACTIVITY_CLASS_NAME);
ActivityInfo activityInfo = intent.resolveActivityInfo(packageManager, PackageManager.GET_ACTIVITIES);
assertThat(activityInfo).isNotNull();
}
代码示例来源:origin: robolectric/robolectric
@Override
public void startActivity(Intent intent) {
ActivityInfo ai = intent.resolveActivityInfo(getTargetContext().getPackageManager(), 0);
try {
Class<? extends Activity> activityClass = Class.forName(ai.name).asSubclass(Activity.class);
controller =
Robolectric.buildActivity(activityClass, intent)
.create()
.postCreate(null)
.start()
.resume()
.postResume()
.visible()
.windowFocusChanged(true);
} catch (ClassNotFoundException e) {
throw new RuntimeException("Could not load activity " + ai.name, e);
}
}
代码示例来源:origin: robolectric/robolectric
@Override
public Activity startActivitySync(final Intent intent) {
ActivityInfo ai = intent.resolveActivityInfo(getTargetContext().getPackageManager(), 0);
try {
Class<? extends Activity> activityClass = Class.forName(ai.name).asSubclass(Activity.class);
return Robolectric.buildActivity(activityClass, intent)
.create()
.postCreate(null)
.start()
.resume()
.postResume()
.visible()
.windowFocusChanged(true)
.get();
} catch (ClassNotFoundException e) {
throw new RuntimeException("Could not load activity " + ai.name, e);
}
}
代码示例来源:origin: android-hacker/VirtualXposed
continue;
ActivityInfo ai = ii.resolveActivityInfo(
getPackageManager(), 0);
if (ai == null) {
代码示例来源:origin: fossasia/pslab-android
@Override
public void onClick(View view) {
Uri selectedUri = Uri.parse(logDirectory.getAbsolutePath());
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(selectedUri, "resource/folder");
if (intent.resolveActivityInfo(getPackageManager(), 0) != null) {
startActivity(intent);
}
}
}, Snackbar.LENGTH_INDEFINITE);
代码示例来源:origin: org.robolectric/robolectric
@Override
public void startActivity(Intent intent) {
ActivityInfo ai = intent.resolveActivityInfo(getTargetContext().getPackageManager(), 0);
try {
Class<? extends Activity> activityClass = Class.forName(ai.name).asSubclass(Activity.class);
controller =
Robolectric.buildActivity(activityClass, intent)
.create()
.postCreate(null)
.start()
.resume()
.postResume()
.visible()
.windowFocusChanged(true);
} catch (ClassNotFoundException e) {
throw new RuntimeException("Could not load activity " + ai.name, e);
}
}
代码示例来源:origin: org.robolectric/robolectric
@Override
public Activity startActivitySync(final Intent intent) {
ActivityInfo ai = intent.resolveActivityInfo(getTargetContext().getPackageManager(), 0);
try {
Class<? extends Activity> activityClass = Class.forName(ai.name).asSubclass(Activity.class);
return Robolectric.buildActivity(activityClass, intent)
.create()
.postCreate(null)
.start()
.resume()
.postResume()
.visible()
.windowFocusChanged(true)
.get();
} catch (ClassNotFoundException e) {
throw new RuntimeException("Could not load activity " + ai.name, e);
}
}
代码示例来源:origin: stackoverflow.com
PackageManager pm = getPackageManager();
Intent queryIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
ActivityInfo af = queryIntent.resolveActivityInfo(pm, 0);
Intent launchIntent = new Intent(Intent.ACTION_MAIN);
launchIntent.setClassName(af.packageName, af.name);
startActivity(launchIntent);
代码示例来源:origin: stackoverflow.com
Intent intent;
Intent queryIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://www.google.com"));
ActivityInfo af = queryIntent.resolveActivityInfo(pm, 0);
intent = new Intent(Intent.ACTION_MAIN);
intent.setClassName(af.packageName, af.name);
代码示例来源:origin: stackoverflow.com
PackageManager pm = getPackageManager();
Intent queryIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
ActivityInfo af = queryIntent.resolveActivityInfo(pm, 0);
Intent launchIntent = new Intent(Intent.ACTION_MAIN);
launchIntent.setClassName(af.packageName, af.name);
startActivity(launchIntent);
代码示例来源:origin: stackoverflow.com
@Override
public void startActivityForResult(Intent i, int reqCode, Bundle b){
boolean activityExists = i.resolveActivityInfo(getPackageManager(), 0) != null;
if(activityExists)
super.startActivityForResult(i, reqCode, b);
else{
if(Intent.ACTION_WEB_SEARCH.equals(i.getAction()) && i.getExtras()!=null){
String query = i.getExtras().getString(SearchManager.QUERY, null);
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.pl/search?q="+query));
boolean browserExists = i.resolveActivityInfo(getPackageManager(), 0) != null;
if(browserExists && query!=null){
startActivity(browserIntent);
return;
}
}
Toast.makeText(this, R.string.error_no_app_for_intent, Toast.LENGTH_LONG).show();
}
}
代码示例来源:origin: stackoverflow.com
Intent it = new Intent(Intent.ACTION_SEND);
it.setType("text/plain");
it.putExtra(Intent.EXTRA_EMAIL, new String[]{emailAddr});
it.putExtra(Intent.EXTRA_SUBJECT, emailSubject);
it.putExtra(Intent.EXTRA_TEXT, emailContent);
it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + emailAddr));
emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ActivityInfo info = emailIntent.resolveActivityInfo(mContext.getPackageManager(), PackageManager.MATCH_DEFAULT_ONLY);
if (info != null) {
it.setPackage(info.packageName);
}
mContext.startActivity(it);
代码示例来源:origin: stackoverflow.com
public static Activity getLaunchActivity()
{
final Class<?> activityThreadClass = Class.forName("android.app.ActivityThread");
final Method methodApp = activityThreadClass.getMethod("currentApplication");
App = (Application) methodApp.invoke(null, (Object[]) null);
Intent launcherIntent = App.getPackageManager().getLaunchIntentForPackage(App.getPackageName());
launchActivityInfo = launcherIntent.resolveActivityInfo(App.getPackageManager(), 0);
Class<?> clazz;
try
{
clazz = Class.forName(launchActivityInfo.name);
if(clazz != null)
return Activity.class.cast(clazz.newInstance());
}
catch (Exception e)
{}
return null;
}
代码示例来源:origin: stackoverflow.com
ActivityInfo ai = intent.resolveActivityInfo(
mContext.getPackageManager(), PackageManager.GET_META_DATA);
if (ai == null) {
代码示例来源:origin: freedom10086/Ruisi
public static void requestHandleFile(Context context, String fileName) {
File fileDir = new File(Environment.getExternalStorageDirectory() + "/" + path + "/");
File file = new File(fileDir + "/" + fileName);
if (fileName.endsWith(".apk")) {
/*********下载完成,点击安装***********/
Uri uri = Uri.fromFile(file);
Intent intent = new Intent(Intent.ACTION_VIEW);
/**********加这个属性是因为使用Context的startActivity方法的话,就需要开启一个新的task**********/
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setDataAndType(uri, "application/vnd.android.package-archive");
context.startActivity(intent);
} else {
Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath() + "/" + path);
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setDataAndType(uri, "*/*");
if (intent.resolveActivityInfo(context.getPackageManager(), 0) != null) {
context.startActivity(intent);
} else {
Toast.makeText(context, "没有打开目录的合适app,请自行打开目录 " + path, Toast.LENGTH_LONG).show();
}
}
}
代码示例来源:origin: souch/SMP
public void openSongFolder(View view) {
final RowSong song = rows.getCurrSong();
if (song == null) {
// err msg ?
return;
}
Uri selectedUri = Uri.fromFile(new File(song.getPath()).getParentFile());
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(selectedUri, "resource/folder");
if (intent.resolveActivityInfo(getPackageManager(), 0) != null) {
startActivity(intent);
}
else {
Toast.makeText(getApplicationContext(),
"no file explorer app installed on your device", Toast.LENGTH_LONG).show();
}
}
代码示例来源:origin: AppLozic/Applozic-Android-SDK
public static void startContactAddActivity(FragmentActivity activity) {
final Intent intent = new Intent(Intent.ACTION_INSERT, ContactsContract.Contacts.CONTENT_URI);
ActivityInfo activityInfo = intent.resolveActivityInfo(activity.getPackageManager(), intent.getFlags());
if (intent.resolveActivity(activity.getPackageManager()) != null && activityInfo.exported) {
activity.startActivity(intent);
}
}
代码示例来源:origin: stackoverflow.com
systemEq.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, PlayerController.getAudioSessionId());
ActivityInfo info = systemEq.resolveActivityInfo(c.getPackageManager(), 0);
if (info != null && !info.name.startsWith("com.android.musicfx")) {
return systemEq;
代码示例来源:origin: gumingwei/WellSwipe
ActivityInfo homeInfo = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME).resolveActivityInfo(manager, 0);
for (int i = 0; i < activityInfoList.size(); i++) {
ActivityManager.RecentTaskInfo info = activityInfoList.get(i);
代码示例来源:origin: klinker24/Android-Blur-Launcher
final ActivityInfo info = originalIntent.resolveActivityInfo(pm, PackageManager.GET_ACTIVITIES);
内容来源于网络,如有侵权,请联系作者删除!