-
Notifications
You must be signed in to change notification settings - Fork 1
/
ColinTreeGoHome.java
41 lines (35 loc) · 1.4 KB
/
ColinTreeGoHome.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package cn.colintree.aix.ColinTreeGoHome;
import android.content.Context;
import android.util.Log;
import com.google.appinventor.components.annotations.*;
import com.google.appinventor.components.common.*;
import com.google.appinventor.components.runtime.*;
import com.google.appinventor.components.runtime.util.*;
import android.app.Activity;
import android.content.Intent;
@DesignerComponent(version = ColinTreeGoHome.VERSION,
description = "by ColinTree at http://aix.colintree.cn",
category = ComponentCategory.EXTENSION,
nonVisible = true,
iconName = "images/extension.png")
@SimpleObject(external = true)
public class ColinTreeGoHome extends AndroidNonvisibleComponent
implements Component {
public static final int VERSION = 1;
private ComponentContainer container;
private Context context;
private static final String LOG_TAG = "ColinTreeGoHome";
public ColinTreeGoHome(ComponentContainer container) {
super(container.$form());
this.container = container;
context = (Context) container.$context();
Log.d(LOG_TAG, "ColinTreeGoHome Created" );
}
@SimpleFunction(description = "Go to Home page (desktop) of the phone")
public void GoHome() {
Intent home = new Intent(Intent.ACTION_MAIN);
home.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
home.addCategory(Intent.CATEGORY_HOME);
context.startActivity(home);
}
}