-
Notifications
You must be signed in to change notification settings - Fork 1
Activity
An activity is a single, focused thing that the user can do. Almost all activities interact with the user, so the Activity class takes care of creating a window for you in which you can place your UI.
With Android Native plugin you may interact with Android Activites. Frist of all you can refer to the main / launcher activity. For example:
using SA.Android.App;
using SA.Android.Content;
...
AN_Intent sendIntent = new AN_Intent();
sendIntent.SetAction(AN_Intent.ACTION_SEND);
sendIntent.PutExtra(AN_Intent.EXTRA_TEXT, "This is my text to send.");
sendIntent.SetType("text/plain");
AN_MainActivity.Instance.StartActivity(sendIntent);
Or you may use AN_ProxyActivity activity, to create a new activity on top of the Unity launcher Activity. And for example, to start for result some AN_Intent. See the example.
using SA.Android.App;
using SA.Android.Content;
...
AN_Intent sendIntent = new AN_Intent();
sendIntent.SetAction(AN_Intent.ACTION_SEND);
sendIntent.PutExtra(AN_Intent.EXTRA_TEXT, "This is my text to send.");
sendIntent.SetType("text/plain");
// Instaed AN_MainActivity
// AN_MainActivity.Instance.StartActivity(sendIntent);
AN_ProxyActivity proxy = new AN_ProxyActivity();
proxy.StartActivityForResult(sendIntent, (result) => {
Debug.Log("Unity: Activity Result: " + result.ResultCode.ToString());
proxy.Finish();
});
The AN_Activity class is base on Google Activity object. Let us know if you need more API related to Activity. Feel free to contact us at https://stansassets.com/
Call this when your activity is done and should be closed.
The ActivityResult is propagated back to whoever launched the activity.
Move the task containing this activity to the back of the activity stack. The activity's order within the task is unchanged
nonRoot param: If false then this only works if the activity is the root of a task; if true it will work for any activity in a task.
Resturns: If the task was moved (or it was already at the back) true is returned, else false.
And here is a small example how to Send Application to background:
using SA.Android.App;
...
AN_MainActivity.Instance.MoveTaskToBack(true);
Reliable and high-quality Unity Development service. Let's Talk!
Website | AssetStore | LinkedIn | Youtube | Scripting Reference
- Build Info
- Dark Mode
- Package Info
- Runtime Permissions
- Run External App
- Immersive Mode
- PackageManager
- Popups & Preloaders
- Rate Us Dialog
- Activity
- Intent
- Settings Page
- Media Player
- Date Picker Dialog
- Time Picker Dialog
- Locale
- Wheel Picker Dialog
- Developer Console Setup
- Connecting to The Service
- Purchase Flow
- Transactions Validation
- Subscriptions
- Licensing
- Getting Started
- Games Sing-in
- Server-side API Access
- Leaderboards
- Achievements
- Saved Games
- Image Manager
- Settings Intent