本文整理了Java中android.content.Intent.setClass()
方法的一些代码示例,展示了Intent.setClass()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Intent.setClass()
方法的具体详情如下:
包路径:android.content.Intent
类名称:Intent
方法名:setClass
暂无
代码示例来源:origin: stackoverflow.com
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
public class ServiceStarter extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Intent i = new Intent("com.prac.test.MyPersistingService");
i.setClass(context, MyPersistingService.class);
context.startService(i);
}
}
代码示例来源:origin: stackoverflow.com
// utility method used to start sub activity
private void startApplicationDetailsActivity() {
// Create intent to start new activity
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setClass(this, InstalledAppDetails.class);
intent.putExtra(APP_PKG_NAME, mCurrentPkgName);
// start new activity to display extended information
startActivityForResult(intent, INSTALLED_APP_DETAILS);
}
代码示例来源:origin: stackoverflow.com
CustomListing currentListing = new CustomListing();
Intent i = new Intent();
Bundle b = new Bundle();
b.putParcelable(Constants.CUSTOM_LISTING, currentListing);
i.putExtras(b);
i.setClass(this, SearchDetailsActivity.class);
startActivity(i);
代码示例来源:origin: stackoverflow.com
Intent newIntent = new Intent();
newIntent.putExtra(PackageUtil.INTENT_ATTR_APPLICATION_INFO, mPkgInfo.applicationInfo);
newIntent.setData(mPackageURI);
newIntent.setClass(this, InstallAppProgress.class);
String installerPackageName = getIntent().getStringExtra(Intent.EXTRA_INSTALLER_PACKAGE_NAME);
if (installerPackageName != null) {
newIntent.putExtra(Intent.EXTRA_INSTALLER_PACKAGE_NAME, installerPackageName);
}
startActivity(newIntent);
代码示例来源:origin: cymcsg/UltimateAndroid
/**
* Launch a new activity with one pair of extended String type data.
*
* @param context
* @param classes
* @param key
* @param value
*/
public static void sendIntent(Context context, Class classes, String key, String value) {
Intent intent = new Intent();
intent.setClass(context, classes);
intent.putExtra(key, value);
context.startActivity(intent);
}
代码示例来源:origin: stackoverflow.com
@Override
public boolean onTap(GeoPoint p, MapView mapView)
{
// ...
Intent intent = new Intent();
intent.setClass(mapView.getContext(), FullscreenView.class);
startActivity(intent);
// ...
}
代码示例来源:origin: jaydenxiao2016/AndroidFire
/**
* 含有Bundle通过Class跳转界面
**/
public void startActivity(Class<?> cls, Bundle bundle) {
Intent intent = new Intent();
intent.setClass(this, cls);
if (bundle != null) {
intent.putExtras(bundle);
}
startActivity(intent);
}
代码示例来源:origin: android-hacker/VirtualXposed
ComponentInfo info = VirtualCore.get().resolveActivityInfo(intent, VUserHandle.myUserId());
if (info != null) {
newIntent.setClass(getHostContext(), StubPendingActivity.class);
newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ComponentInfo info = VirtualCore.get().resolveServiceInfo(intent, VUserHandle.myUserId());
if (info != null) {
newIntent.setClass(getHostContext(), StubPendingService.class);
newIntent.setClass(getHostContext(), StubPendingReceiver.class);
return null;
newIntent.putExtra("_VA_|_user_id_", VUserHandle.myUserId());
newIntent.putExtra("_VA_|_intent_", intent);
newIntent.putExtra("_VA_|_creator_", creator);
newIntent.putExtra("_VA_|_from_inner_", true);
return newIntent;
代码示例来源:origin: cymcsg/UltimateAndroid
/**
* Launch a new activity with one Parcelable data.
*
* @param context
* @param classes
* @param key
* @param value
*/
public static void sendIntent(Context context, Class classes, String key, Parcelable value) {
Intent intent = new Intent();
intent.setClass(context, classes);
intent.putExtra(key, value);
context.startActivity(intent);
}
代码示例来源:origin: stackoverflow.com
public void onClick(View v) {
if(v == mOk) {
// Start subactivity to actually install the application
Intent newIntent = new Intent();
...
newIntent.setClass(this, InstallAppProgress.class);
...
startActivity(newIntent);
finish();
} else if(v == mCancel) {
// Cancel and finish
finish();
}
}
代码示例来源:origin: jaydenxiao2016/AndroidFire
/**
* 含有Bundle通过Class跳转界面
**/
public void startActivityForResult(Class<?> cls, Bundle bundle,
int requestCode) {
Intent intent = new Intent();
intent.setClass(this, cls);
if (bundle != null) {
intent.putExtras(bundle);
}
startActivityForResult(intent, requestCode);
}
代码示例来源:origin: android-hacker/VirtualXposed
switch (type) {
case 1:
cloneFilter.setClass(VirtualCore.get().getContext(), StubPendingReceiver.class);
break;
case 2:
if (VirtualCore.get().resolveActivityInfo(intent, VUserHandle.myUserId()) != null) {
cloneFilter.setClass(VirtualCore.get().getContext(), StubPendingActivity.class);
cloneFilter.setFlags(intent.getFlags());
if (iBinder != null) {
Parcelable activityForToken = VActivityManager.get().getActivityForToken(iBinder);
if (activityForToken != null) {
cloneFilter.putExtra("_VA_|_caller_", activityForToken);
break;
case 4:
if (VirtualCore.get().resolveServiceInfo(intent, VUserHandle.myUserId()) != null) {
cloneFilter.setClass(VirtualCore.get().getContext(), StubPendingService.class);
break;
return null;
cloneFilter.putExtra("_VA_|_user_id_", VUserHandle.myUserId());
cloneFilter.putExtra("_VA_|_intent_", intent);
cloneFilter.putExtra("_VA_|_creator_", creator);
cloneFilter.putExtra("_VA_|_from_inner_", true);
代码示例来源:origin: daniulive/SmarterStreaming
public void onClick(View v) {
if (mCamera != null) {
mCamera.stopPreview();
mCamera.release();
mCamera = null;
}
Intent intent = new Intent();
intent.setClass(CameraPublishActivity.this, RecorderManager.class);
intent.putExtra("RecoderDir", recDir);
startActivity(intent);
}
}
代码示例来源:origin: stackoverflow.com
Intent i = new Intent();
i.setClass(this, MyActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
代码示例来源:origin: joyoyao/superCleanMaster
/** 含有Bundle通过Class跳转界面 **/
protected void startActivity(Class<?> cls, Bundle bundle) {
Intent intent = new Intent();
intent.setClass(mContext, cls);
if (bundle != null) {
intent.putExtras(bundle);
}
startActivity(intent);
}
代码示例来源:origin: daniulive/SmarterStreaming
public void onClick(View v) {
if (isPlaying || isRecording) {
return;
}
Intent intent = new Intent();
intent.setClass(SmartPlayer.this, RecorderManager.class);
intent.putExtra("RecoderDir", recDir);
startActivity(intent);
}
}
代码示例来源:origin: stackoverflow.com
class ServiceStarter extends BroadcastReceiver {
@Override
public void onReceive(Context _context, Intent _intent) {
Intent i = new Intent("com.prac.test.MyPersistingService");
i.setClass(_context, ServiceCode.class);
_context.startService(i);
}
}
代码示例来源:origin: jaydenxiao2016/AndroidFire
/**
* 含有Bundle通过Class跳转界面
**/
public void startActivityForResult(Class<?> cls, Bundle bundle,
int requestCode) {
Intent intent = new Intent();
intent.setClass(getActivity(), cls);
if (bundle != null) {
intent.putExtras(bundle);
}
startActivityForResult(intent, requestCode);
}
代码示例来源:origin: daniulive/SmarterStreaming
public void onClick(View v) {
Intent intent_rec = new Intent();
intent_rec.setClass(MainActivity.this, RecorderManager.class);
intent_rec.putExtra("RecorderDir", recDir);
startActivity(intent_rec);
}
}
代码示例来源:origin: k9mail/k-9
/**
* Start {@link DatabaseUpgradeService}.
*
* @param context
* The {@link Context} used to start this service.
*/
public static void startService(Context context) {
Intent i = new Intent();
i.setClass(context, DatabaseUpgradeService.class);
i.setAction(DatabaseUpgradeService.ACTION_START_SERVICE);
context.startService(i);
}
内容来源于网络,如有侵权,请联系作者删除!