Android examples for android.content:Intent
get Explicit Intent
import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import java.util.List; public class Main{ public static Intent getExplicitIntent(Context context, Intent implicitIntent) {/*from w ww. ja v a 2s .com*/ PackageManager pm = context.getPackageManager(); List<ResolveInfo> resolveInfo = pm.queryIntentServices( implicitIntent, 0); if (resolveInfo == null || resolveInfo.size() != 1) { return null; } ResolveInfo serviceInfo = resolveInfo.get(0); String packageName = serviceInfo.serviceInfo.packageName; String className = serviceInfo.serviceInfo.name; ComponentName component = new ComponentName(packageName, className); Intent explicitIntent = new Intent(implicitIntent); explicitIntent.setComponent(component); return explicitIntent; } }