本文整理匯總了Java中android.support.v4.content.IntentCompat.makeMainActivity方法的典型用法代碼示例。如果您正苦於以下問題:Java IntentCompat.makeMainActivity方法的具體用法?Java IntentCompat.makeMainActivity怎麽用?Java IntentCompat.makeMainActivity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v4.content.IntentCompat
的用法示例。
在下文中一共展示了IntentCompat.makeMainActivity方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getParentActivityIntent
import android.support.v4.content.IntentCompat; //導入方法依賴的package包/類
public Intent getParentActivityIntent(Activity paramActivity)
{
String str = NavUtils.getParentActivityName(paramActivity);
if (str == null) {
return null;
}
ComponentName localComponentName = new ComponentName(paramActivity, str);
try
{
if (NavUtils.getParentActivityName(paramActivity, localComponentName) == null) {
return IntentCompat.makeMainActivity(localComponentName);
}
Intent localIntent = new Intent().setComponent(localComponentName);
return localIntent;
}
catch (PackageManager.NameNotFoundException localNameNotFoundException)
{
Log.e("NavUtils", "getParentActivityIntent: bad parentActivityName '" + str + "' in manifest");
}
return null;
}
示例2: getParentActivityIntent
import android.support.v4.content.IntentCompat; //導入方法依賴的package包/類
@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;
}
}
示例3: getParentActivityIntent
import android.support.v4.content.IntentCompat; //導入方法依賴的package包/類
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);
}
}
示例4: getParentActivityIntent
import android.support.v4.content.IntentCompat; //導入方法依賴的package包/類
public static Intent getParentActivityIntent(Context context, ComponentName componentname)
throws android.content.pm.PackageManager.NameNotFoundException
{
String s = getParentActivityName(context, componentname);
if (s == null)
{
return null;
}
componentname = new ComponentName(componentname.getPackageName(), s);
if (getParentActivityName(context, componentname) == null)
{
return IntentCompat.makeMainActivity(componentname);
} else
{
return (new Intent()).setComponent(componentname);
}
}
示例5: getParentActivityIntent
import android.support.v4.content.IntentCompat; //導入方法依賴的package包/類
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;
}
示例6: onCreate
import android.support.v4.content.IntentCompat; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
Preferences.applyTheme(this);
getDelegate().installViewFactory();
getDelegate().onCreate(savedInstanceState);
super.onCreate(savedInstanceState);
//Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
//setSupportActionBar(toolbar);
//getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getFragmentManager().beginTransaction()
.replace(android.R.id.content, new PreferencesFragment()).commit();
//addPreferences(R.xml.task_preferences);
//Preferences.sync(getPreferencesManager());
mListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
//Preferences.sync(getPreferenceManager(), key);
if (key.equals(getString(R.string.pref_theme))) {
finish();
//change to launch into activity upon retheme
final Intent intent = IntentCompat.makeMainActivity(new ComponentName(
PreferencesActivity.this, TaskListActivity.class));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
}
}
};
}
示例7: onCreate
import android.support.v4.content.IntentCompat; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
Preferences.applyTheme(this);
getDelegate().installViewFactory();
getDelegate().onCreate(savedInstanceState);
super.onCreate(savedInstanceState);
setToolbar();
addPreferencesFromResource(R.xml.preferences);
Preferences.sync(getPreferenceManager());
mListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
Preferences.sync(getPreferenceManager(), key);
if (key.equals(getString(R.string.pref_theme))) {
finish();
//change to launch into activity upon retheme
final Intent intent = IntentCompat.makeMainActivity(new ComponentName(
SettingsActivity.this, TaskListActivity.class));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
}
/*if(key.equals(R.string.pref_help)){
finish();
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://android.bowenchin.com")));
}*/
}
};
findPreference(getApplicationContext().getString(R.string.title_instructions)).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Intent intent = new Intent(SettingsActivity.this, WalkThroughActivity.class);
startActivity(intent);
return false;
}
});
}
示例8: restartApp
import android.support.v4.content.IntentCompat; //導入方法依賴的package包/類
/**
* Restarts app.
*
* @param activity the activity
*/
public static void restartApp(Activity activity) {
activity.finish();
ComponentName componentName = new ComponentName(activity, WeekScheduleActivity.class);
final Intent intent = IntentCompat.makeMainActivity(componentName);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
activity.startActivity(intent);
}
示例9: onBackPressed
import android.support.v4.content.IntentCompat; //導入方法依賴的package包/類
@Override
public void onBackPressed() {
if(restart) {
super.onBackPressed();
final Intent intent = IntentCompat.makeMainActivity(new ComponentName(
AppSettingsActivity.this, MainActivity.class));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
} else
super.onBackPressed();
}
示例10: getParentActivityIntent
import android.support.v4.content.IntentCompat; //導入方法依賴的package包/類
/**
* 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;
}