Java Code Examples for android.content.Intent#setClass()

The following examples show how to use android.content.Intent#setClass() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: XCL-Charts   File: GaugeChartActivity.java    License: Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example 2
@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);
}
 
Example 3
Source Project: Pasta-for-Spotify   File: PlayerService.java    License: Apache License 2.0 6 votes vote down vote up
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);
    }
}
 
Example 4
Source Project: Android-Keyboard   File: LatinIME.java    License: Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 5
@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);
}
 
Example 6
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;
    }
}
 
Example 7
Source Project: Android-SDK   File: MainActivity.java    License: MIT License 6 votes vote down vote up
@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 ) );
  }
}
 
Example 8
@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);
    }
}
 
Example 9
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);
}
 
Example 10
Source Project: Camera2   File: CameraTest.java    License: Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 11
Source Project: KlyphMessenger   File: Session.java    License: MIT License 5 votes vote down vote up
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;
}
 
Example 12
Source Project: Android-Keyboard   File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 13
@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);
}
 
Example 14
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);
}
 
Example 15
Source Project: accountBook   File: MainActivity.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * 跳转至心愿墙界面
 * @param v
 */
private void openWishWind(View v){
    Intent intent = new Intent();
    intent.setClass(MainActivity.this, WishActivity.class);
    this.startActivity(intent);
}
 
Example 16
protected Intent browseIntent(String path) {
    Intent result = new Intent();
    result.setClass(this, ApiDemos.class);
    result.putExtra("com.example.android.apis.Path", path);
    return result;
}
 
Example 17
public static Intent getIntent(Context context, String action) {
    Intent intent = new Intent();
    intent.setAction(action);
    intent.setClass(context, AccountTransferService.class);
    return intent;
}
 
Example 18
Source Project: GPT   File: RemapingUtil.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * 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());
}
 
Example 19
Source Project: MyHearts   File: SettingActivity.java    License: Apache License 2.0 4 votes vote down vote up
@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;

        }

    }
 
Example 20
Source Project: UltimateAndroid   File: BasicUtils.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * 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);
}