當前位置: 首頁>>代碼示例>>Java>>正文


Java IntentCompat類代碼示例

本文整理匯總了Java中android.support.v4.content.IntentCompat的典型用法代碼示例。如果您正苦於以下問題:Java IntentCompat類的具體用法?Java IntentCompat怎麽用?Java IntentCompat使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


IntentCompat類屬於android.support.v4.content包,在下文中一共展示了IntentCompat類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getHtmlText

import android.support.v4.content.IntentCompat; //導入依賴的package包/類
public String getHtmlText() {
    String result = this.mIntent.getStringExtra(IntentCompat.EXTRA_HTML_TEXT);
    if (result != null) {
        return result;
    }
    CharSequence text = getText();
    if (text instanceof Spanned) {
        return Html.toHtml((Spanned) text);
    }
    if (text != null) {
        return ShareCompat.IMPL.escapeHtml(text);
    }
    return result;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:15,代碼來源:ShareCompat.java

示例2: addShowScenarioShortcut

import android.support.v4.content.IntentCompat; //導入依賴的package包/類
public static Intent addShowScenarioShortcut(Context context, Choice choice) {
    Intent addShowScenarioShortcutIntent = new Intent(context, AddShowScenarioShortcutActivity.class);
    addShowScenarioShortcutIntent = IntentCompat.makeRestartActivityTask(addShowScenarioShortcutIntent.getComponent());
    addShowScenarioShortcutIntent.setAction(Intent.ACTION_VIEW);
    addShowScenarioShortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    Serializer serializer = new Persister();
    ByteArrayOutputStream choiceOutputStream = new ByteArrayOutputStream();
    try {
        serializer.write(choice, choiceOutputStream);
    } catch (Exception e) {
        Log.d(TAG, e.toString());
    }
    String choiceXml = choiceOutputStream.toString();
    addShowScenarioShortcutIntent.putExtra(EXTRA_CHOICE_XML, choiceXml);
    return addShowScenarioShortcutIntent;
}
 
開發者ID:nicholasrout,項目名稱:shortstories,代碼行數:17,代碼來源:IntentUtil.java

示例3: onActivityCreated

import android.support.v4.content.IntentCompat; //導入依賴的package包/類
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
        @Override
        public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
            //Preferences.sync(getPreferenceManager(), key);
            if (key.equals(getActivity().getString(R.string.pref_theme))) {
                getActivity().finish();
                final Intent intent = getActivity().getIntent();
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK);
                getActivity().startActivity(intent);
            }
        }
    };
}
 
開發者ID:bowenchin,項目名稱:RemindrApp-Android,代碼行數:17,代碼來源:PreferencesFragment.java

示例4: onPostExecute

import android.support.v4.content.IntentCompat; //導入依賴的package包/類
@Override
protected void onPostExecute(Status status){
	super.onPostExecute(status);
	if (status == Status.OK){
		if (loginRequest){
			Intent result = new Intent();
			setResult(Activity.RESULT_OK, result);
			LoginActivity.this.finish();
		}
		else {
			Intent intent = new Intent(LoginActivity.this, ProfileActivity.class);
			intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK);
			startActivity(intent);
		}
	}
	else if (status == Status.COOKIE_EXPIRED){
		Toast.makeText(LoginActivity.this, "Cookie expired, please login", Toast.LENGTH_LONG).show();
	}
	else {
		Toast.makeText(LoginActivity.this, "Could not login", Toast.LENGTH_LONG).show();
	}
}
 
開發者ID:stuxo,項目名稱:PTHAndroid,代碼行數:23,代碼來源:LoginActivity.java

示例5: 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;
}
 
開發者ID:ChiangC,項目名稱:FMTech,代碼行數:22,代碼來源:NavUtils.java

示例6: PostUploadNotifier

import android.support.v4.content.IntentCompat; //導入依賴的package包/類
public PostUploadNotifier(Post post) {
    // add the uploader to the notification bar
    mNotificationManager = (NotificationManager) SystemServiceFactory.get(mContext,
            Context.NOTIFICATION_SERVICE);

    mNotificationBuilder = new NotificationCompat.Builder(getApplicationContext());
    mNotificationBuilder.setSmallIcon(android.R.drawable.stat_sys_upload);

    Intent notificationIntent = new Intent(mContext, post.isPage() ? PagesActivity.class : PostsActivity.class);
    notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK
            | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK);
    notificationIntent.setAction(Intent.ACTION_MAIN);
    notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER);
    notificationIntent.setData((Uri.parse("custom://wordpressNotificationIntent"
            + post.getLocalTableBlogId())));
    notificationIntent.putExtra(PostsActivity.EXTRA_VIEW_PAGES, post.isPage());
    PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, notificationIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    mNotificationBuilder.setContentIntent(pendingIntent);

    mNotificationId = (new Random()).nextInt() + post.getLocalTableBlogId();
    startForeground(mNotificationId, mNotificationBuilder.build());
}
 
開發者ID:ldsddn,項目名稱:wordpress_app_android,代碼行數:25,代碼來源:PostUploadService.java

示例7: onBackPressed

import android.support.v4.content.IntentCompat; //導入依賴的package包/類
@Override
public void onBackPressed() {
    if (!mHasNavigationDrawer) {
        super.onBackPressed();
        return;
    }

    DrawerLayout drawer = mNavigationDrawer.mLayout;
    if (drawer.isDrawerVisible(GravityCompat.START)) {
        drawer.closeDrawer(GravityCompat.START);
    } else {
        if (NavigationDrawerEntry.FIND_BAGGER.equals(mSelectedDrawerItem)) {
            super.onBackPressed();
        } else {
            Intent intent = BaggersListActivity.createLaunchIntent(this, mPrefs.getCity());
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK);
            startActivityWithoutTransition(intent);
            finish();
        }
    }
}
 
開發者ID:Nilhcem,項目名稱:bblfr-android,代碼行數:22,代碼來源:NavigationDrawerActivity.java

示例8: startActivities

import android.support.v4.content.IntentCompat; //導入依賴的package包/類
/**
 * Start the task stack constructed by this builder. The Context used to obtain
 * this builder must be an Activity.
 *
 * <p>On devices that do not support API level 11 or higher the topmost activity
 * will be started as a new task. On devices that do support API level 11 or higher
 * the new task stack will be created in its entirety.</p>
 *
 * @param options Additional options for how the Activity should be started.
 * See {@link android.content.Context#startActivity(Intent, Bundle)
 */
public void startActivities(Bundle options) {
    if (mIntents.isEmpty()) {
        throw new IllegalStateException(
                "No intents added to TaskStackBuilder; cannot startActivities");
    }

    Intent[] intents = mIntents.toArray(new Intent[mIntents.size()]);
    intents[0] = new Intent(intents[0]).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
            IntentCompat.FLAG_ACTIVITY_CLEAR_TASK |
            IntentCompat.FLAG_ACTIVITY_TASK_ON_HOME);
    if (!ContextCompat.startActivities(mSourceContext, intents, options)) {
        Intent topIntent = new Intent(intents[intents.length - 1]);
        topIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        mSourceContext.startActivity(topIntent);
    }
}
 
開發者ID:bestarandyan,項目名稱:ShoppingMall,代碼行數:28,代碼來源:TaskStackBuilder.java

示例9: 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;
    }
}
 
開發者ID:bestarandyan,項目名稱:ShoppingMall,代碼行數:20,代碼來源:NavUtils.java

示例10: onActivityCreated

import android.support.v4.content.IntentCompat; //導入依賴的package包/類
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
        @Override
        public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
            //Preferences.sync(getPreferenceManager(), key);
            if (key.equals(getActivity().getString(R.string.pref_theme))) {
                getActivity().finish();
                final Intent intent = getActivity().getIntent();
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK);
                getActivity().startActivity(intent);
            }
            /*if(key.equals(getActivity().getString(R.string.pref_help))){
                getActivity().finish();
                startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://android.bowenchin.com")));
            }*/
        }
    };
}
 
開發者ID:bowenchin,項目名稱:MaterialTasksApp-Android,代碼行數:21,代碼來源:SettingsFragment.java

示例11: onCreate

import android.support.v4.content.IntentCompat; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_settings);

    Toolbar toolbar = getActionBarToolbar();
    toolbar.setTitle(R.string.title_settings);
    toolbar.setNavigationIcon(R.drawable.ic_up);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            navigateUpToFromChild(SettingsActivity.this,
                    IntentCompat.makeMainActivity(new ComponentName(SettingsActivity.this,
                            BrowseSessionsActivity.class)));
        }
    });

    if (savedInstanceState == null) {
        getFragmentManager().beginTransaction()
                .add(R.id.container, new SettingsFragment())
                .commit();
    }
}
 
開發者ID:The-WebOps-Club,項目名稱:saarang-iosched,代碼行數:24,代碼來源:SettingsActivity.java

示例12: 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);
    }
}
 
開發者ID:vishnudevk,項目名稱:MiBandDecompiled,代碼行數:17,代碼來源:NavUtils.java

示例13: doRestart

import android.support.v4.content.IntentCompat; //導入依賴的package包/類
public static void doRestart(@NonNull Context cxt) {
    try {
        PackageManager pm = cxt.getPackageManager();
        if (pm != null) {
            Intent intent = pm.getLaunchIntentForPackage(cxt.getPackageName());
            if (intent != null) {
                ComponentName componentName = intent.getComponent();
                Intent mainIntent = IntentCompat.makeRestartActivityTask(componentName);
                mainIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
                        | Intent.FLAG_ACTIVITY_NEW_TASK
                        | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                cxt.startActivity(mainIntent);

                Runtime.getRuntime().exit(0);
            } else {
                LogHelper.d(TAG, "Was not able to restart application, intent null");
            }
        } else {
            LogHelper.d(TAG, "Was not able to restart application, PM null");
        }
    } catch (Exception e) {
        LogHelper.e(TAG, e, "Was not able to restart application");
    }
}
 
開發者ID:avluis,項目名稱:Hentoid,代碼行數:25,代碼來源:Helper.java

示例14: 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);
    }
}
 
開發者ID:Hamz-a,項目名稱:MyCTFWriteUps,代碼行數:18,代碼來源:NavUtils.java

示例15: onReceive

import android.support.v4.content.IntentCompat; //導入依賴的package包/類
@Override
public void onReceive(final Context context, Intent intent) {

    // Gets the intent, check if it matches our secret code
    if (Intent.ACTION_NEW_OUTGOING_CALL.equals(intent.getAction()) &&
            intent.getExtras() != null) {
        Intent launcher = new Intent(context, MainActivity_.class);
        //These flags are added to make the new mainActivity in the home stack.
        //i.e. back button returns to home not dialer.
        launcher.addFlags(IntentCompat.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK | IntentCompat.FLAG_ACTIVITY_TASK_ON_HOME);
        String phoneNumber = intent.getExtras().getString(android.content.Intent.EXTRA_PHONE_NUMBER);
        if (Pref.OpenPIN().exists())
            if (("*#" + Pref.OpenPIN().get()).equals(phoneNumber))
                // Launch the main app!!
                launchActivity(context, launcher);
    }
}
 
開發者ID:SecrecySupportTeam,項目名稱:Secrecy_fDroid_DEPRECIATED,代碼行數:18,代碼來源:OutgoingCallReceiver.java


注:本文中的android.support.v4.content.IntentCompat類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。