下面列出了android.support.v4.content.IntentCompat#makeMainActivity ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public static Intent getParentActivityIntent(Context context, ComponentName componentname)
{
String s = getParentActivityName(context, componentname);
if (s == null)
{
return null;
}
ComponentName componentname1 = new ComponentName(componentname.getPackageName(), s);
if (getParentActivityName(context, componentname1) == null)
{
return IntentCompat.makeMainActivity(componentname1);
} else
{
return (new Intent()).setComponent(componentname1);
}
}
public static Intent getParentActivityIntent(Context context, Class class1)
{
String s = getParentActivityName(context, new ComponentName(context, class1));
if (s == null)
{
return null;
}
ComponentName componentname = new ComponentName(context, s);
if (getParentActivityName(context, componentname) == null)
{
return IntentCompat.makeMainActivity(componentname);
} else
{
return (new Intent()).setComponent(componentname);
}
}
@Override
public Intent getParentActivityIntent(Activity activity) {
String parentName = NavUtils.getParentActivityName(activity);
if (parentName == null) return null;
// If the parent itself has no parent, generate a main activity intent.
final ComponentName target = new ComponentName(activity, parentName);
try {
final String grandparent = NavUtils.getParentActivityName(activity, target);
final Intent parentIntent = grandparent == null
? IntentCompat.makeMainActivity(target)
: new Intent().setComponent(target);
return parentIntent;
} catch (NameNotFoundException e) {
Log.e(TAG, "getParentActivityIntent: bad parentActivityName '" + parentName +
"' in manifest");
return null;
}
}
@Override
public Intent getParentActivityIntent(Activity activity) {
String parentName = NavUtils.getParentActivityName(activity);
if (parentName == null) return null;
// If the parent itself has no parent, generate a main activity intent.
final ComponentName target = new ComponentName(activity, parentName);
try {
final String grandparent = NavUtils.getParentActivityName(activity, target);
final Intent parentIntent = grandparent == null
? IntentCompat.makeMainActivity(target)
: new Intent().setComponent(target);
return parentIntent;
} catch (NameNotFoundException e) {
Log.e(TAG, "getParentActivityIntent: bad parentActivityName '" + parentName +
"' in manifest");
return null;
}
}
@Override
public Intent getParentActivityIntent(Activity activity) {
String parentName = NavUtils.getParentActivityName(activity);
if (parentName == null) return null;
// If the parent itself has no parent, generate a main activity intent.
final ComponentName target = new ComponentName(activity, parentName);
try {
final String grandparent = NavUtils.getParentActivityName(activity, target);
final Intent parentIntent = grandparent == null
? IntentCompat.makeMainActivity(target)
: new Intent().setComponent(target);
return parentIntent;
} catch (NameNotFoundException e) {
Log.e(TAG, "getParentActivityIntent: bad parentActivityName '" + parentName +
"' in manifest");
return null;
}
}
@Override
public Intent getParentActivityIntent(Activity activity) {
String parentName = NavUtils.getParentActivityName(activity);
if (parentName == null) return null;
// If the parent itself has no parent, generate a main activity intent.
final ComponentName target = new ComponentName(activity, parentName);
try {
final String grandparent = NavUtils.getParentActivityName(activity, target);
final Intent parentIntent = grandparent == null
? IntentCompat.makeMainActivity(target)
: new Intent().setComponent(target);
return parentIntent;
} catch (NameNotFoundException e) {
Log.e(TAG, "getParentActivityIntent: bad parentActivityName '" + parentName +
"' in manifest");
return null;
}
}
@Override
public Intent getParentActivityIntent(Activity activity) {
String parentName = NavUtils.getParentActivityName(activity);
if (parentName == null) return null;
// If the parent itself has no parent, generate a main activity intent.
final ComponentName target = new ComponentName(activity, parentName);
try {
final String grandparent = NavUtils.getParentActivityName(activity, target);
final Intent parentIntent = grandparent == null
? IntentCompat.makeMainActivity(target)
: new Intent().setComponent(target);
return parentIntent;
} catch (NameNotFoundException e) {
Log.e(TAG, "getParentActivityIntent: bad parentActivityName '" + parentName +
"' in manifest");
return null;
}
}
public Intent getParentActivityIntent(Activity activity) {
Intent intent = null;
String parentName = NavUtils.getParentActivityName(activity);
if (parentName != null) {
ComponentName target = new ComponentName(activity, parentName);
try {
intent = NavUtils.getParentActivityName(activity, target) == null ? IntentCompat.makeMainActivity(target) : new Intent().setComponent(target);
} catch (NameNotFoundException e) {
Log.e(NavUtils.TAG, "getParentActivityIntent: bad parentActivityName '" + parentName + "' in manifest");
}
}
return intent;
}
public static Intent getParentActivityIntent(Context context, Class<?> sourceActivityClass) throws NameNotFoundException {
String parentActivity = getParentActivityName(context, new ComponentName(context, sourceActivityClass));
if (parentActivity == null) {
return null;
}
ComponentName target = new ComponentName(context, parentActivity);
return getParentActivityName(context, target) == null ? IntentCompat.makeMainActivity(target) : new Intent().setComponent(target);
}
public static Intent getParentActivityIntent(Context context, ComponentName componentName) throws NameNotFoundException {
String parentActivity = getParentActivityName(context, componentName);
if (parentActivity == null) {
return null;
}
ComponentName target = new ComponentName(componentName.getPackageName(), parentActivity);
return getParentActivityName(context, target) == null ? IntentCompat.makeMainActivity(target) : new Intent().setComponent(target);
}
/**
* Obtain an {@link Intent} that will launch an explicit target activity
* specified by sourceActivityClass's {@link #PARENT_ACTIVITY} <meta-data>
* element in the application's manifest.
*
* @param context Context for looking up the activity component for sourceActivityClass
* @param sourceActivityClass {@link java.lang.Class} object for an Activity class
* @return a new Intent targeting the defined parent activity of sourceActivity
* @throws NameNotFoundException if the ComponentName for sourceActivityClass is invalid
*/
public static Intent getParentActivityIntent(Context context, Class<?> sourceActivityClass)
throws NameNotFoundException {
String parentActivity = getParentActivityName(context,
new ComponentName(context, sourceActivityClass));
if (parentActivity == null) return null;
// If the parent itself has no parent, generate a main activity intent.
final ComponentName target = new ComponentName(context, parentActivity);
final String grandparent = getParentActivityName(context, target);
final Intent parentIntent = grandparent == null
? IntentCompat.makeMainActivity(target)
: new Intent().setComponent(target);
return parentIntent;
}
/**
* Obtain an {@link Intent} that will launch an explicit target activity
* specified by sourceActivityClass's {@link #PARENT_ACTIVITY} <meta-data>
* element in the application's manifest.
*
* @param context Context for looking up the activity component for the source activity
* @param componentName ComponentName for the source Activity
* @return a new Intent targeting the defined parent activity of sourceActivity
* @throws NameNotFoundException if the ComponentName for sourceActivityClass is invalid
*/
public static Intent getParentActivityIntent(Context context, ComponentName componentName)
throws NameNotFoundException {
String parentActivity = getParentActivityName(context, componentName);
if (parentActivity == null) return null;
// If the parent itself has no parent, generate a main activity intent.
final ComponentName target = new ComponentName(
componentName.getPackageName(), parentActivity);
final String grandparent = getParentActivityName(context, target);
final Intent parentIntent = grandparent == null
? IntentCompat.makeMainActivity(target)
: new Intent().setComponent(target);
return parentIntent;
}
/**
* Obtain an {@link Intent} that will launch an explicit target activity
* specified by sourceActivityClass's {@link #PARENT_ACTIVITY} <meta-data>
* element in the application's manifest.
*
* @param context Context for looking up the activity component for sourceActivityClass
* @param sourceActivityClass {@link java.lang.Class} object for an Activity class
* @return a new Intent targeting the defined parent activity of sourceActivity
* @throws NameNotFoundException if the ComponentName for sourceActivityClass is invalid
*/
public static Intent getParentActivityIntent(Context context, Class<?> sourceActivityClass)
throws NameNotFoundException {
String parentActivity = getParentActivityName(context,
new ComponentName(context, sourceActivityClass));
if (parentActivity == null) return null;
// If the parent itself has no parent, generate a main activity intent.
final ComponentName target = new ComponentName(context, parentActivity);
final String grandparent = getParentActivityName(context, target);
final Intent parentIntent = grandparent == null
? IntentCompat.makeMainActivity(target)
: new Intent().setComponent(target);
return parentIntent;
}
/**
* Obtain an {@link Intent} that will launch an explicit target activity
* specified by sourceActivityClass's {@link #PARENT_ACTIVITY} <meta-data>
* element in the application's manifest.
*
* @param context Context for looking up the activity component for the source activity
* @param componentName ComponentName for the source Activity
* @return a new Intent targeting the defined parent activity of sourceActivity
* @throws NameNotFoundException if the ComponentName for sourceActivityClass is invalid
*/
public static Intent getParentActivityIntent(Context context, ComponentName componentName)
throws NameNotFoundException {
String parentActivity = getParentActivityName(context, componentName);
if (parentActivity == null) return null;
// If the parent itself has no parent, generate a main activity intent.
final ComponentName target = new ComponentName(
componentName.getPackageName(), parentActivity);
final String grandparent = getParentActivityName(context, target);
final Intent parentIntent = grandparent == null
? IntentCompat.makeMainActivity(target)
: new Intent().setComponent(target);
return parentIntent;
}
/**
* Obtain an {@link Intent} that will launch an explicit target activity
* specified by sourceActivityClass's {@link #PARENT_ACTIVITY} <meta-data>
* element in the application's manifest.
*
* @param context Context for looking up the activity component for sourceActivityClass
* @param sourceActivityClass {@link java.lang.Class} object for an Activity class
* @return a new Intent targeting the defined parent activity of sourceActivity
* @throws NameNotFoundException if the ComponentName for sourceActivityClass is invalid
*/
public static Intent getParentActivityIntent(Context context, Class<?> sourceActivityClass)
throws NameNotFoundException {
String parentActivity = getParentActivityName(context,
new ComponentName(context, sourceActivityClass));
if (parentActivity == null) return null;
// If the parent itself has no parent, generate a main activity intent.
final ComponentName target = new ComponentName(context, parentActivity);
final String grandparent = getParentActivityName(context, target);
final Intent parentIntent = grandparent == null
? IntentCompat.makeMainActivity(target)
: new Intent().setComponent(target);
return parentIntent;
}
/**
* Obtain an {@link Intent} that will launch an explicit target activity
* specified by sourceActivityClass's {@link #PARENT_ACTIVITY} <meta-data>
* element in the application's manifest.
*
* @param context Context for looking up the activity component for the source activity
* @param componentName ComponentName for the source Activity
* @return a new Intent targeting the defined parent activity of sourceActivity
* @throws NameNotFoundException if the ComponentName for sourceActivityClass is invalid
*/
public static Intent getParentActivityIntent(Context context, ComponentName componentName)
throws NameNotFoundException {
String parentActivity = getParentActivityName(context, componentName);
if (parentActivity == null) return null;
// If the parent itself has no parent, generate a main activity intent.
final ComponentName target = new ComponentName(
componentName.getPackageName(), parentActivity);
final String grandparent = getParentActivityName(context, target);
final Intent parentIntent = grandparent == null
? IntentCompat.makeMainActivity(target)
: new Intent().setComponent(target);
return parentIntent;
}
/**
* Obtain an {@link Intent} that will launch an explicit target activity
* specified by sourceActivityClass's {@link #PARENT_ACTIVITY} <meta-data>
* element in the application's manifest.
*
* @param context Context for looking up the activity component for sourceActivityClass
* @param sourceActivityClass {@link java.lang.Class} object for an Activity class
* @return a new Intent targeting the defined parent activity of sourceActivity
* @throws NameNotFoundException if the ComponentName for sourceActivityClass is invalid
*/
public static Intent getParentActivityIntent(Context context, Class<?> sourceActivityClass)
throws NameNotFoundException {
String parentActivity = getParentActivityName(context,
new ComponentName(context, sourceActivityClass));
if (parentActivity == null) return null;
// If the parent itself has no parent, generate a main activity intent.
final ComponentName target = new ComponentName(context, parentActivity);
final String grandparent = getParentActivityName(context, target);
final Intent parentIntent = grandparent == null
? IntentCompat.makeMainActivity(target)
: new Intent().setComponent(target);
return parentIntent;
}
/**
* Obtain an {@link Intent} that will launch an explicit target activity
* specified by sourceActivityClass's {@link #PARENT_ACTIVITY} <meta-data>
* element in the application's manifest.
*
* @param context Context for looking up the activity component for the source activity
* @param componentName ComponentName for the source Activity
* @return a new Intent targeting the defined parent activity of sourceActivity
* @throws NameNotFoundException if the ComponentName for sourceActivityClass is invalid
*/
public static Intent getParentActivityIntent(Context context, ComponentName componentName)
throws NameNotFoundException {
String parentActivity = getParentActivityName(context, componentName);
if (parentActivity == null) return null;
// If the parent itself has no parent, generate a main activity intent.
final ComponentName target = new ComponentName(
componentName.getPackageName(), parentActivity);
final String grandparent = getParentActivityName(context, target);
final Intent parentIntent = grandparent == null
? IntentCompat.makeMainActivity(target)
: new Intent().setComponent(target);
return parentIntent;
}
/**
* Obtain an {@link Intent} that will launch an explicit target activity
* specified by sourceActivityClass's {@link #PARENT_ACTIVITY} <meta-data>
* element in the application's manifest.
*
* @param context Context for looking up the activity component for sourceActivityClass
* @param sourceActivityClass {@link java.lang.Class} object for an Activity class
* @return a new Intent targeting the defined parent activity of sourceActivity
* @throws NameNotFoundException if the ComponentName for sourceActivityClass is invalid
*/
public static Intent getParentActivityIntent(Context context, Class<?> sourceActivityClass)
throws NameNotFoundException {
String parentActivity = getParentActivityName(context,
new ComponentName(context, sourceActivityClass));
if (parentActivity == null) return null;
// If the parent itself has no parent, generate a main activity intent.
final ComponentName target = new ComponentName(context, parentActivity);
final String grandparent = getParentActivityName(context, target);
final Intent parentIntent = grandparent == null
? IntentCompat.makeMainActivity(target)
: new Intent().setComponent(target);
return parentIntent;
}
/**
* Obtain an {@link Intent} that will launch an explicit target activity
* specified by sourceActivityClass's {@link #PARENT_ACTIVITY} <meta-data>
* element in the application's manifest.
*
* @param context Context for looking up the activity component for the source activity
* @param componentName ComponentName for the source Activity
* @return a new Intent targeting the defined parent activity of sourceActivity
* @throws NameNotFoundException if the ComponentName for sourceActivityClass is invalid
*/
public static Intent getParentActivityIntent(Context context, ComponentName componentName)
throws NameNotFoundException {
String parentActivity = getParentActivityName(context, componentName);
if (parentActivity == null) return null;
// If the parent itself has no parent, generate a main activity intent.
final ComponentName target = new ComponentName(
componentName.getPackageName(), parentActivity);
final String grandparent = getParentActivityName(context, target);
final Intent parentIntent = grandparent == null
? IntentCompat.makeMainActivity(target)
: new Intent().setComponent(target);
return parentIntent;
}