android.content.Intent#setClass ( )源码实例Demo

下面列出了android.content.Intent#setClass ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: XCL-Charts   文件: GaugeChartActivity.java
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    super.onOptionsItemSelected(item);
    switch(item.getItemId())
    {
    case Menu.FIRST+1: 
    	//String chartsHelp[] = getResources().getStringArray(R.array.chartsHelp);	        
    	//String URL = chartsHelp[mSelected]; 	        	
    	String URL =getResources().getString(R.string.helpurl);	        		        
     Uri uri = Uri.parse(URL);  
     Intent intent2 = new Intent(Intent.ACTION_VIEW, uri);  
     startActivity(intent2);  
     finish();
        break;
    case Menu.FIRST+2:
     Intent intent = new Intent();  
		intent.setClass(GaugeChartActivity.this,AboutActivity.class);    				
		startActivity(intent); 	        
        break;
    }
    return true;
}
 
源代码2 项目: YiBo   文件: SocialGraphItemClickListener.java
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
		long id) {
	BaseAdapter adapter = AdapterUtil.getAdapter(parent.getAdapter());
	if (adapter == null || position >= adapter.getCount()) {
		return;
	}
	
	User user = (User)adapter.getItem(position);
	if (user == null) {
           return;
       }

	Intent intent = new Intent();
	intent.putExtra("USER", user);
	intent.setClass(parent.getContext(), ProfileActivity.class);
	context.startActivity(intent);
}
 
源代码3 项目: Pasta-for-Spotify   文件: PlayerService.java
private void onError(String message) {
    if (spotifyPlayer != null) {
        errorCount++;
        if (errorCount > 5 && errorCount < 20) {
            if (PreferenceUtils.isDebug(this))
                pasta.showToast(message + ", attempting to restart...");

            stopService(new Intent(this, PlayerService.class));

            Intent intent = new Intent(PlayerService.ACTION_INIT);
            intent.setClass(this, PlayerService.class);
            intent.putExtra(PlayerService.EXTRA_TOKEN, playerConfig.oauthToken);
            intent.putExtra(PlayerService.EXTRA_CLIENT_ID, playerConfig.clientId);
            startService(intent);
            errorCount = 20;
        } else if (PreferenceUtils.isDebug(this))
            pasta.showToast(message);
    }
}
 
源代码4 项目: Android-Keyboard   文件: LatinIME.java
void launchSettings(final String extraEntryValue) {
    mInputLogic.commitTyped(null,LastComposedWord.NOT_A_SEPARATOR);
    requestHideSelf(0);
    final MainKeyboardView mainKeyboardView = KeyboardSwitcher.getInstance().getMainKeyboardView();
    if (mainKeyboardView != null) {
        mainKeyboardView.closing();
    }
    final Intent intent = new Intent();
    intent.setClass(LatinIME.this, SettingsActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
            | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
            | Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.putExtra(SettingsActivity.EXTRA_SHOW_HOME_AS_UP, false);
    intent.putExtra(SettingsActivity.EXTRA_ENTRY_KEY, extraEntryValue);
    startActivity(intent);
}
 
@Override
protected void onRegistered(String registrationId) {
  // Inform the sender service that the registration id has changed. If the sender service
  // had buffered a message because no registration id was previously available, this intent
  // will cause it to send that message.
  Intent sendBuffered = new Intent();
  final String ignoredData = "";
  sendBuffered.putExtra(AndroidChannelConstants.MESSAGE_SENDER_SVC_GCM_REGID_CHANGE, ignoredData);
  sendBuffered.setClass(this, AndroidMessageSenderService.class);
  startService(sendBuffered);

  // Inform the Ticl service that the registration id has changed. This will cause it to send
  // a message to the data center and update the GCM registration id stored at the data center.
  Intent updateServer = ProtocolIntents.InternalDowncalls.newNetworkAddrChangeIntent();
  updateServer.setClassName(this, new AndroidTiclManifest(this).getTiclServiceClass());
  startService(updateServer);
}
 
源代码6 项目: a   文件: ReceivingSharedActivity.java
private boolean openUrl(String text) {
    if (StringUtils.isTrimEmpty(text)) {
        return false;
    }
    String[] urls = text.split("\\s");
    StringBuilder result = new StringBuilder();
    for (String url : urls) {
        if (url.matches("http.+"))
            result.append("\n").append(url.trim());
    }
    if (result.length() > 1) {
        MApplication.getConfigPreferences().edit()
                .putString("shared_url", result.toString())
                .apply();

        Intent intent = new Intent();
        intent.setClass(ReceivingSharedActivity.this, MyMainActivity.class);
        this.startActivity(intent);
        return false;
    } else {
        return true;
    }
}
 
源代码7 项目: Android-SDK   文件: MainActivity.java
@Override
public void onActivityResult( int requestCode, int resultCode, Intent data )
{
  if( resultCode != RESULT_OK )
    return;

  switch( requestCode )
  {
    case Defaults.SELECT_PHOTO:
    case Defaults.CAMERA_REQUEST:
      data.setClass( getBaseContext(), UploadingActivity.class );
      startActivityForResult( data, Defaults.URL_REQUEST );
      break;

    case Defaults.URL_REQUEST:
      welcomeTextField.setText( getResources().getText( R.string.welcome_text ) );
      urlField.setText( (String) data.getExtras().get( Defaults.DATA_TAG ) );
      takePhotoButton.setText( getResources().getText( R.string.takeAnotherPhoto ) );
  }
}
 
@Override  // runs on UI thread
public void handleMessage(Message inputMessage) {
    int what = inputMessage.what;
    Log.d(TAG, "CameraHandler [" + this + "]: what=" + what);

    CameraCaptureActivity activity = mWeakActivity.get();
    if (activity == null) {
        Log.w(TAG, "CameraHandler.handleMessage: activity is null");
        return;
    }

    switch (what) {
        case MSG_SET_SURFACE_TEXTURE:
            activity.handleSetSurfaceTexture((SurfaceTexture) inputMessage.obj);
            break;
        case MSG_STOP_RECORDING:
            Intent intent = new Intent();
            intent.putExtra("video", Environment.getExternalStorageDirectory() + "/test.mp4");
	        intent.setClass(activity, PlayMovieSurfaceActivity.class);
            activity.startActivity(intent);
            break;
        default:
            throw new RuntimeException("unknown msg " + what);
    }
}
 
public static void start(Activity activity, String teamId, String announceId) {
    Intent intent = new Intent();
    intent.setClass(activity, AdvancedTeamAnnounceActivity.class);
    intent.putExtra(EXTRA_TID, teamId);
    if (announceId != null) {
        intent.putExtra(EXTRA_AID, announceId);
    }
    activity.startActivity(intent);
}
 
源代码10 项目: Camera2   文件: CameraTest.java
private void checkActivityLeak(String action) throws Exception
{
    final int TEST_COUNT = 5;
    Intent intent = new Intent(action);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setClass(getInstrumentation().getTargetContext(),
            CameraActivity.class);
    ArrayList<WeakReference<Activity>> refs =
            new ArrayList<WeakReference<Activity>>();
    for (int i = 0; i < TEST_COUNT; i++)
    {
        Activity activity = getInstrumentation().startActivitySync(intent);
        refs.add(new WeakReference<Activity>(activity));
        activity.finish();
        getInstrumentation().waitForIdleSync();
        activity = null;
    }
    Runtime.getRuntime().gc();
    Runtime.getRuntime().runFinalization();
    Runtime.getRuntime().gc();
    int refCount = 0;
    for (WeakReference<Activity> c : refs)
    {
        if (c.get() != null)
        {
            refCount++;
        }
    }
    // If applications are leaking activity, every reference is reachable.
    assertTrue(refCount != TEST_COUNT);
}
 
源代码11 项目: KlyphMessenger   文件: Session.java
private Intent getLoginActivityIntent(AuthorizationRequest request) {
    Intent intent = new Intent();
    intent.setClass(getStaticContext(), LoginActivity.class);
    intent.setAction(request.getLoginBehavior().toString());

    // Let LoginActivity populate extras appropriately
    AuthorizationClient.AuthorizationRequest authClientRequest = request.getAuthorizationClientRequest();
    Bundle extras = LoginActivity.populateIntentExtras(authClientRequest);
    intent.putExtras(extras);

    return intent;
}
 
源代码12 项目: Android-Keyboard   文件: MainActivity.java
private void invokeSettingsOfThisIme() {
    final Intent intent = new Intent();
    intent.setClass(this, SettingsActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
            | Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.putExtra(SettingsActivity.EXTRA_ENTRY_KEY,
            SettingsActivity.EXTRA_ENTRY_VALUE_APP_ICON);
    startActivity(intent);
}
 
源代码13 项目: YiBo   文件: HomePageEditMessageClickListener.java
@Override
public void onClick(View v) {
	Intent intent = new Intent();
	Bundle bundle = new Bundle();		
	bundle.putInt("TYPE", Constants.EDIT_TYPE_MESSAGE);
	bundle.putBoolean("IS_INBOX", false);
	intent.putExtras(bundle);

	intent.setClass(context, EditDirectMessageActivity.class);
	((Activity)context).startActivity(intent);
}
 
源代码14 项目: bcm-android   文件: AmeNotificationService.java
public static PendingIntent getIntentData(@Nullable String data, int action, int id) {
    Intent notificationIntent = new Intent();
    notificationIntent.putExtra(ACTION, action);
    notificationIntent.putExtra(ACTION_DATA, data);
    notificationIntent.setClass(AppContextHolder.APP_CONTEXT, AmeNotificationService.class);

    return PendingIntent.getService(AppContextHolder.APP_CONTEXT, (1<<24)^id, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
}
 
源代码15 项目: accountBook   文件: MainActivity.java
/**
 * 跳转至心愿墙界面
 * @param v
 */
private void openWishWind(View v){
    Intent intent = new Intent();
    intent.setClass(MainActivity.this, WishActivity.class);
    this.startActivity(intent);
}
 
源代码16 项目: codeexamples-android   文件: ApiDemos.java
protected Intent browseIntent(String path) {
    Intent result = new Intent();
    result.setClass(this, ApiDemos.class);
    result.putExtra("com.example.android.apis.Path", path);
    return result;
}
 
源代码17 项目: identity-samples   文件: AccountTransferService.java
public static Intent getIntent(Context context, String action) {
    Intent intent = new Intent();
    intent.setAction(action);
    intent.setClass(context, AccountTransferService.class);
    return intent;
}
 
源代码18 项目: GPT   文件: RemapingUtil.java
/**
 * remapReceiverIntent
 *
 * @param hostCtx      Context
 * @param originIntent Intent
 */
public static void remapReceiverIntent(Context hostCtx, Intent originIntent) {
    // 注意:pkg设置了插件包名的话,要替换成宿主包名,不然插件收不到广播
    String pkg = originIntent.getPackage();
    if (pkg != null && GPTPackageManager.getInstance(hostCtx).getPackageInfo(pkg) != null) {
        originIntent.setPackage(hostCtx.getPackageName());
    }

    if (originIntent.getComponent() == null) {
        return;
    }

    TargetMapping targetMapping = TargetManager.getInstance(hostCtx).getTargetMapping(
            originIntent.getComponent().getPackageName());
    if (targetMapping == null) {
        return;
    }

    // 获取插件信息
    GPTPackageInfo gptPkgInfo = GPTPackageManager.getInstance(hostCtx).getPackageInfo(
            targetMapping.getPackageName());
    if (gptPkgInfo == null) {
        return;
    }

    String targetReceiver = originIntent.getComponent().getClassName();
    ActivityInfo recvInfo = targetMapping.getReceiverInfo(targetReceiver);
    if (recvInfo == null) {
        return;
    }

    GPTComponentInfo info = new GPTComponentInfo();
    info.packageName = targetMapping.getPackageName();
    info.className = targetReceiver;
    originIntent.addCategory(info.toString());
    switch (gptPkgInfo.extProcess) {
        case Constants.GPT_PROCESS_DEFAULT:
        default:
            if (!gptPkgInfo.isUnionProcess) {
                originIntent.setClass(hostCtx, BroadcastReceiverProxyExt.class);
            } else {
                originIntent.setClass(hostCtx, BroadcastReceiverProxy.class);
            }
            break;
    }

    // 注意:pkg要替换成宿主,不然,插件收不到广播
    originIntent.setPackage(hostCtx.getPackageName());
}
 
源代码19 项目: MyHearts   文件: SettingActivity.java
@Override
    public void onClick(View v) {
        Intent intent = new Intent();
        switch (v.getId()) {
            case R.id.img_back:
                finish();
                break;


            case R.id.setting_opinion:

                if (mMyUser == null) {
                    intent.setClass(this, LoginActivity.class);
                } else {
                    intent.setClass(this, FeedActivity.class);
                    intent.putExtra(Contants.USER_NAME, mMyUser.getUsername());
                }
                startActivity(intent);
                break;

            case R.id.setting_share:

                break;

            case R.id.goupdate_password:
//                BmobQuery<MyUser> bmobQuery = new BmobQuery<>();
//                String phone = "13718989054";
//                String sql = "select * from _User where mobilePhoneNumber = ?";
//                bmobQuery.setSQL(sql);
//                bmobQuery.setPreparedParams(new Object[]{phone});
//                bmobQuery.doSQLQuery( new SQLQueryListener<MyUser>() {
//                    @Override
//                    public void done(BmobQueryResult<MyUser> bmobQueryResult, BmobException e) {
//                        if (e == null){
//                            List<MyUser> results = bmobQueryResult.getResults();
//                            if (results.size()>0){
//                                MyUser myUser1 = results.get(0);
//                                Log.d("wuyinlei", myUser1.getUsername());
//                            }
//                        }
//                    }
//                });

                if (mMyUser == null) {
                    intent.setClass(this, LoginActivity.class);
                } else {
                    intent.setClass(this, ChangePasswordActivity.class);
                    intent.putExtra(Contants.USER_NAME, mMyUser.getUsername());
                    intent.putExtra(Contants.OBJECT_ID, mMyUser.getObjectId());
                }
                startActivity(intent);
                break;

            case R.id.version_check:

                break;

            case R.id.clear_cache:
                DataCleanManager.clearAllCache(this);  //清理app缓存
                new MaterialDialog.Builder(this)
                        .title(getResources().getString(R.string.clear_tip))
                        .content(getResources().getString(R.string.clear_success))
                        .positiveText(getResources().getString(R.string.ok))
                        .onPositive((dialog, which) -> mCurrentCache.setText("0 KB")).show();
                break;

            case R.id.setting_byme:
                // StringBuffer sb = new StringBuffer();

                WebActivity.runActivity(this, "My Github,Welcome star", "https://github.com/wuyinlei");
                break;

            case R.id.checkbox_isshare_homepage:

                break;
            default:
                break;

        }

    }
 
源代码20 项目: UltimateAndroid   文件: BasicUtils.java
/**
 * 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);
}
 
 方法所在类
 同类方法