List of usage examples for android.app ActivityManagerNative getDefault
@UnsupportedAppUsage static public IActivityManager getDefault()
From source file:android.app.Activity.java
/** * Return the name of the activity that invoked this activity. This is * who the data in {@link #setResult setResult()} will be sent to. You * can use this information to validate that the recipient is allowed to * receive the data./*from w w w . j a v a2 s.c om*/ * * <p class="note">Note: if the calling activity is not expecting a result (that is it * did not use the {@link #startActivityForResult} * form that includes a request code), then the calling package will be * null. * * @return The ComponentName of the activity that will receive your * reply, or null if none. */ public ComponentName getCallingActivity() { try { return ActivityManagerNative.getDefault().getCallingActivity(mToken); } catch (RemoteException e) { return null; } }
From source file:android.app.Activity.java
/** * Call this when your activity is done and should be closed. The * ActivityResult is propagated back to whoever launched you via * onActivityResult()./*from w w w .ja va2 s . com*/ */ public void finish() { if (mParent == null) { int resultCode; Intent resultData; synchronized (this) { resultCode = mResultCode; resultData = mResultData; } if (false) Log.v(TAG, "Finishing self: token=" + mToken); try { if (resultData != null) { resultData.prepareToLeaveProcess(); } if (ActivityManagerNative.getDefault().finishActivity(mToken, resultCode, resultData)) { mFinished = true; } } catch (RemoteException e) { // Empty } } else { mParent.finishFromChild(this); } }
From source file:android.app.Activity.java
/** * Finish this activity as well as all activities immediately below it * in the current task that have the same affinity. This is typically * used when an application can be launched on to another task (such as * from an ACTION_VIEW of a content type it understands) and the user * has used the up navigation to switch out of the current task and in * to its own task. In this case, if the user has navigated down into * any other activities of the second application, all of those should * be removed from the original task as part of the task switch. * * <p>Note that this finish does <em>not</em> allow you to deliver results * to the previous activity, and an exception will be thrown if you are trying * to do so.</p>// ww w . j a v a2 s. co m */ public void finishAffinity() { if (mParent != null) { throw new IllegalStateException("Can not be called from an embedded activity"); } if (mResultCode != RESULT_CANCELED || mResultData != null) { throw new IllegalStateException("Can not be called to deliver a result"); } try { if (ActivityManagerNative.getDefault().finishActivityAffinity(mToken)) { mFinished = true; } } catch (RemoteException e) { // Empty } }
From source file:android.app.Activity.java
/** * Force finish another activity that you had previously started with * {@link #startActivityForResult}.//from w ww.j ava 2 s. com * * @param requestCode The request code of the activity that you had * given to startActivityForResult(). If there are multiple * activities started with this request code, they * will all be finished. */ public void finishActivity(int requestCode) { if (mParent == null) { try { ActivityManagerNative.getDefault().finishSubActivity(mToken, mEmbeddedID, requestCode); } catch (RemoteException e) { // Empty } } else { mParent.finishActivityFromChild(this, requestCode); } }
From source file:android.app.Activity.java
/** * This is called when a child activity of this one calls its * finishActivity()./*from w ww.j a v a 2 s.co m*/ * * @param child The activity making the call. * @param requestCode Request code that had been used to start the * activity. */ public void finishActivityFromChild(Activity child, int requestCode) { try { ActivityManagerNative.getDefault().finishSubActivity(mToken, child.mEmbeddedID, requestCode); } catch (RemoteException e) { // Empty } }
From source file:android.app.Activity.java
/** * Create a new PendingIntent object which you can hand to others * for them to use to send result data back to your * {@link #onActivityResult} callback. The created object will be either * one-shot (becoming invalid after a result is sent back) or multiple * (allowing any number of results to be sent through it). * /*from w ww . j a v a 2 s.c o m*/ * @param requestCode Private request code for the sender that will be * associated with the result data when it is returned. The sender can not * modify this value, allowing you to identify incoming results. * @param data Default data to supply in the result, which may be modified * by the sender. * @param flags May be {@link PendingIntent#FLAG_ONE_SHOT PendingIntent.FLAG_ONE_SHOT}, * {@link PendingIntent#FLAG_NO_CREATE PendingIntent.FLAG_NO_CREATE}, * {@link PendingIntent#FLAG_CANCEL_CURRENT PendingIntent.FLAG_CANCEL_CURRENT}, * {@link PendingIntent#FLAG_UPDATE_CURRENT PendingIntent.FLAG_UPDATE_CURRENT}, * or any of the flags as supported by * {@link Intent#fillIn Intent.fillIn()} to control which unspecified parts * of the intent that can be supplied when the actual send happens. * * @return Returns an existing or new PendingIntent matching the given * parameters. May return null only if * {@link PendingIntent#FLAG_NO_CREATE PendingIntent.FLAG_NO_CREATE} has been * supplied. * * @see PendingIntent */ public PendingIntent createPendingResult(int requestCode, Intent data, int flags) { String packageName = getPackageName(); try { data.prepareToLeaveProcess(); IIntentSender target = ActivityManagerNative.getDefault().getIntentSender( ActivityManager.INTENT_SENDER_ACTIVITY_RESULT, packageName, mParent == null ? mToken : mParent.mToken, mEmbeddedID, requestCode, new Intent[] { data }, null, flags, null, UserHandle.myUserId()); return target != null ? new PendingIntent(target) : null; } catch (RemoteException e) { // Empty } return null; }
From source file:android.app.Activity.java
/** * Change the desired orientation of this activity. If the activity * is currently in the foreground or otherwise impacting the screen * orientation, the screen will immediately be changed (possibly causing * the activity to be restarted). Otherwise, this will be used the next * time the activity is visible.//from w ww . j a va2 s.c o m * * @param requestedOrientation An orientation constant as used in * {@link ActivityInfo#screenOrientation ActivityInfo.screenOrientation}. */ public void setRequestedOrientation(int requestedOrientation) { if (mParent == null) { try { ActivityManagerNative.getDefault().setRequestedOrientation(mToken, requestedOrientation); } catch (RemoteException e) { // Empty } } else { mParent.setRequestedOrientation(requestedOrientation); } }
From source file:android.app.Activity.java
/** * Return the current requested orientation of the activity. This will * either be the orientation requested in its component's manifest, or * the last requested orientation given to * {@link #setRequestedOrientation(int)}. * //from w w w .j a va 2s .c o m * @return Returns an orientation constant as used in * {@link ActivityInfo#screenOrientation ActivityInfo.screenOrientation}. */ public int getRequestedOrientation() { if (mParent == null) { try { return ActivityManagerNative.getDefault().getRequestedOrientation(mToken); } catch (RemoteException e) { // Empty } } else { return mParent.getRequestedOrientation(); } return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; }
From source file:android.app.Activity.java
/** * Return the identifier of the task this activity is in. This identifier * will remain the same for the lifetime of the activity. * /* www. j av a 2 s . c om*/ * @return Task identifier, an opaque integer. */ public int getTaskId() { try { return ActivityManagerNative.getDefault().getTaskForActivity(mToken, false); } catch (RemoteException e) { return -1; } }
From source file:android.app.Activity.java
/** * Return whether this activity is the root of a task. The root is the * first activity in a task.//from w w w . ja va 2 s.c o m * * @return True if this is the root activity, else false. */ public boolean isTaskRoot() { try { return ActivityManagerNative.getDefault().getTaskForActivity(mToken, true) >= 0; } catch (RemoteException e) { return false; } }