当前位置: 首页>>代码示例>>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;未经允许,请勿转载。