Android的定制启动器(像蹒跚学步的锁)启动器、Android

2023-09-07 02:03:03 作者:求神不如拜我

我想提出一个儿童的应用程序,我想一个孩子锁添加到它,就像一个在名为幼儿锁的应用程序。幼儿锁要求你当锁被打开,允许禁用home键设置默认启动。 我将如何做到这一点?

I am making a children's app and I would like to add a child lock to it, just like the one on the app called "Toddler lock". Toddler lock asks you to set the default launcher when the lock is turned on which allows the home button to be disabled. How would I do this?

推荐答案

好了,所以香港专业教育学院有一个粗略的工作的例子在这里:

Ok so ive got a rough working example here:

创建两个活动和两种布局,在主要版面,一个通用的按钮。其他的布局可能只是有一个空白的<的LinearLayout>

这是我的表现是这样的:

This is what my manifest looks like:

        <activity
        android:name=".MainActivity"
        android:label="@string/title_activity_main"
        android:launchMode="singleTop">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".secondact"
        android:label="@string/secondtitle">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.HOME" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
        </activity>

注意&LT;类机器人:名称=android.intent.category.HOME/&GT; 的第二个活动

下面是我的主要活动code:

Here is the code from my main activity:

       @Override
       public void onResume()
        {
       super.onResume();
       Button btn = (Button)findViewById(R.id.startBtn);
       btn.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
    Intent startMain = new Intent(Intent.ACTION_MAIN, null);
    startMain.addCategory(Intent.CATEGORY_HOME);
    startActivity(startMain);


}
   });
        }

在我的第二个活动,我有:

价值 15 美元的 Android 启动器,究竟好用在哪里

And in my second activity i have:

@Override
public void startActivity(Intent intent)
{
    super.startActivity(intent);

}

当我点击startbtn我明白你在说什么的对话,你会得到chooose发射或secondactivity,并选择始终使用。后退按钮仍然可以让你的家,但希望这有助于。这个问题可以帮助你进一步指出:在Android的应用程序学步禁用主页按钮