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


Java Intent.setComponent方法代碼示例

本文整理匯總了Java中android.content.Intent.setComponent方法的典型用法代碼示例。如果您正苦於以下問題:Java Intent.setComponent方法的具體用法?Java Intent.setComponent怎麽用?Java Intent.setComponent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.Intent的用法示例。


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

示例1: onClick

import android.content.Intent; //導入方法依賴的package包/類
@Override
public void onClick(View view) {
    int position = (int) view.getTag();

    long artistId = mData.get(position).mArtistId;

    String artistName = mData.get(position).mArtistName;

    Intent intent = new Intent();
    intent.putExtra(Constants.ARTIST_ID, artistId);
    intent.putExtra(Constants.ARTIST_NAME, artistName);
    intent.putExtra(Constants.WHICH_DETAIL_PAGE, Constants.ARTIST_DETAIL);

    ComponentName componentName = new ComponentName(Constants.MUSIC_PACKAGE_NAME,
            Constants.DETAIL_PACKAGE_NAME);

    intent.setComponent(componentName);

    mContext.startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(
            ((AppCompatActivity) mContext), new Pair<View, String>(mAlbum,
                    mAlbumTransitionName)).toBundle());
}
 
開發者ID:komamj,項目名稱:KomaMusic,代碼行數:23,代碼來源:ArtistsAdapter.java

示例2: startPitService

import android.content.Intent; //導入方法依賴的package包/類
private void startPitService() {
    // TODO 其實,有一種更好的辦法……敬請期待
    String pname = IPC.getCurrentProcessName();
    int process = PluginClientHelper.getProcessInt(pname);

    ComponentName cn = PluginPitService.makeComponentName(mContext, process);
    if (LOG) {
        LogDebug.d(TAG, "startPitService: Start " + cn);
    }

    Intent intent = new Intent();
    intent.setComponent(cn);

    try {
        mContext.startService(intent);
    } catch (Exception e) {
        // 就算AMS出了問題(如system_server掛了,概率極低,和低配ROM有關),最多也就是服務容易被係統回收,但不能讓它“不幹活”
        e.printStackTrace();
    }
}
 
開發者ID:wangyupeng1-iri,項目名稱:springreplugin,代碼行數:21,代碼來源:PluginServiceServer.java

示例3: stopServiceToken

import android.content.Intent; //導入方法依賴的package包/類
public boolean stopServiceToken(ComponentName cn, IBinder token, int startId) throws Exception {
    Service service = mTokenServices.get(token);
    if (service != null) {
        Integer lastId = mServiceTaskIds.get(token);
        if (lastId == null) {
            return false;
        }
        if (startId != lastId) {
            return false;
        }
        Intent intent = new Intent();
        intent.setComponent(cn);
        ServiceInfo info = PluginManager.getInstance().resolveServiceInfo(intent, 0);
        if (info != null) {
            handleOnUnbindOne(intent);
            handleOnDestroyOne(info);
            return true;
        }
    }
    return false;
}
 
開發者ID:amikey,項目名稱:DroidPlugin,代碼行數:22,代碼來源:ServcesManager.java

示例4: createExplicitFromImplicitIntent

import android.content.Intent; //導入方法依賴的package包/類
/***
 * Android L (lollipop, API 21) introduced a new problem when trying to invoke implicit intent,
 * "java.lang.IllegalArgumentException: Service Intent must be explicit"
 * <p>
 * If you are using an implicit intent, and know only 1 target would answer this intent,
 * This method will help you turn the implicit intent into the explicit form.
 * <p>
 * Inspired from SO answer: http://stackoverflow.com/a/26318757/1446466
 *
 * @param context
 * @param implicitIntent - The original implicit intent
 * @return Explicit Intent created from the implicit original intent
 */
public static Intent createExplicitFromImplicitIntent(Context context, Intent implicitIntent) {
    // Retrieve all services that can match the given intent
    PackageManager pm = context.getPackageManager();
    List<ResolveInfo> resolveInfo = pm.queryIntentServices(implicitIntent, 0);

    // Make sure only one match was found
    if (resolveInfo == null || resolveInfo.size() != 1) {
        return null;
    }

    // Get component info and create ComponentName
    ResolveInfo serviceInfo = resolveInfo.get(0);
    String packageName = serviceInfo.serviceInfo.packageName;
    String className = serviceInfo.serviceInfo.name;
    ComponentName component = new ComponentName(packageName, className);

    // Create a new intent. Use the old one for extras and such reuse
    Intent explicitIntent = new Intent(implicitIntent);

    // Set the component to be explicit
    explicitIntent.setComponent(component);

    return explicitIntent;
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:38,代碼來源:Utils.java

示例5: a

import android.content.Intent; //導入方法依賴的package包/類
private void a(Context context) {
    if (!(g.a(context).b() || !a.a(context).i() || a.a(context).n())) {
        try {
            Intent intent = new Intent();
            intent.setComponent(new ComponentName(context, "com.xiaomi.push.service" +
                    ".XMPushService"));
            intent.setAction("com.xiaomi.push.network_status_changed");
            context.startService(intent);
        } catch (Throwable e) {
            b.a(e);
        }
    }
    if (d.d(context) && g.a(context).f()) {
        g.a(context).c();
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:17,代碼來源:NetworkStatusReceiver.java

示例6: intentForPosition

import android.content.Intent; //導入方法依賴的package包/類
public Intent intentForPosition(int position) {
    DisplayResolveInfo dri = mList.get(position);

    Intent intent = new Intent(dri.origIntent != null
            ? dri.origIntent : mIntent);
    intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT
            | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
    ActivityInfo ai = dri.ri.activityInfo;
    intent.setComponent(new ComponentName(
            ai.applicationInfo.packageName, ai.name));
    return intent;
}
 
開發者ID:coding-dream,項目名稱:TPlayer,代碼行數:13,代碼來源:ResolverActivity.java

示例7: openAppActivity

import android.content.Intent; //導入方法依賴的package包/類
public static boolean openAppActivity(Context context,
                                      String packageName,
                                      String activityName) {
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    ComponentName cn = new ComponentName(packageName, activityName);
    intent.setComponent(cn);
    try {
        context.startActivity(intent);
        return true;
    } catch (ActivityNotFoundException e) {
        return false;
    }
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:16,代碼來源:TDevice.java

示例8: startActivityForProfile

import android.content.Intent; //導入方法依賴的package包/類
public void startActivityForProfile(ComponentName component, UserHandleCompat user,
        Rect sourceBounds, Bundle opts) {
    Intent launchIntent = new Intent(Intent.ACTION_MAIN);
    launchIntent.addCategory(Intent.CATEGORY_LAUNCHER);
    launchIntent.setComponent(component);
    launchIntent.setSourceBounds(sourceBounds);
    launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    mContext.startActivity(launchIntent, opts);
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:10,代碼來源:LauncherAppsCompatV16.java

示例9: requestShowKeyboardShortcuts

import android.content.Intent; //導入方法依賴的package包/類
/**
 * Request the Keyboard Shortcuts screen to show up. This will trigger
 * {@link #onProvideKeyboardShortcuts} to retrieve the shortcuts for the foreground activity.
 */
public final void requestShowKeyboardShortcuts() {
    Intent intent = new Intent(Intent.ACTION_SHOW_KEYBOARD_SHORTCUTS);
    intent.setComponent(new ComponentName(KEYBOARD_SHORTCUTS_RECEIVER_PKG_NAME,
            KEYBOARD_SHORTCUTS_RECEIVER_CLASS_NAME));
    sendBroadcast(intent);
}
 
開發者ID:JessYanCoding,項目名稱:ProgressManager,代碼行數:11,代碼來源:a.java

示例10: openSettings

import android.content.Intent; //導入方法依賴的package包/類
public static void openSettings(Activity context, String action) {
    Intent intent = new Intent();
    ComponentName comp = new ComponentName("com.android.settings", action);
    intent.setComponent(comp);
    intent.setAction("android.intent.action.VIEW");
    context.startActivityForResult(intent, 0);
}
 
開發者ID:jeasinlee,項目名稱:AndroidBasicLibs,代碼行數:8,代碼來源:SystemUtils.java

示例11: onListItemClick

import android.content.Intent; //導入方法依賴的package包/類
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    Map<String, String> item = (Map<String, String>)l.getItemAtPosition(position);
    String className = item.get("class");
    Intent intent = new Intent();
    intent.setComponent(new ComponentName(this, className));
    intent.putExtra("name", item.get("name"));
    intent.putExtra("data", item.get("data"));
    startActivity(intent);
}
 
開發者ID:alibaba,項目名稱:Virtualview-Android,代碼行數:11,代碼來源:ScrollerListActivity.java

示例12: getComponentNameIntent

import android.content.Intent; //導入方法依賴的package包/類
/**
 * 獲取其他應用的Intent
 *
 * @param packageName 包名
 * @param className   全類名
 * @return 意圖
 */
public static Intent getComponentNameIntent(String packageName, String className, Bundle bundle) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    if (bundle != null)
        intent.putExtras(bundle);
    ComponentName cn = new ComponentName(packageName, className);
    intent.setComponent(cn);
    return intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
 
開發者ID:ChunweiDu,項目名稱:Utils,代碼行數:16,代碼來源:IntentUtil.java

示例13: openSetting

import android.content.Intent; //導入方法依賴的package包/類
/**
 * 打開網絡設置界麵
 */
public static void openSetting(Activity activity) {
    Intent intent = new Intent("/");
    ComponentName cm = new ComponentName("com.android.settings",
            "com.android.settings.WirelessSettings");
    intent.setComponent(cm);
    intent.setAction("android.intent.action.VIEW");
    activity.startActivityForResult(intent, 0);
}
 
開發者ID:chengkun123,項目名稱:ReadMark,代碼行數:12,代碼來源:NetworkUtils.java

示例14: openAppActivity

import android.content.Intent; //導入方法依賴的package包/類
public static boolean openAppActivity(Context context, String packageName,
                                      String activityName) {
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    ComponentName cn = new ComponentName(packageName, activityName);
    intent.setComponent(cn);
    try {
        context.startActivity(intent);
        return true;
    } catch (Exception e) {
        return false;
    }
}
 
開發者ID:yangxp108,項目名稱:MVPArms_Fragment-fragment,代碼行數:14,代碼來源:DeviceUtils.java

示例15: createShortcutIntent

import android.content.Intent; //導入方法依賴的package包/類
private Intent createShortcutIntent(String activity, String shortcutName, ShortcutIconResource shortcutIcon, String action) {
	Intent shortcutIntent = new Intent();
	shortcutIntent.setComponent(new ComponentName(this.getPackageName(), activity));
	shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
	shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
	Intent intent = new Intent();
	intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
	intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, shortcutName);
	intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, shortcutIcon);
	intent.setAction(action);
	return intent;
}
 
開發者ID:tiberiusteng,項目名稱:financisto1-holo,代碼行數:13,代碼來源:PreferencesActivity.java


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