无论何时启动服务,Android全屏都无法正常工作

时间:2012-09-11 10:22:31

标签: android

对于kindle fire中的应用程序,我想让屏幕没有软键。

为此我将我的清单更新为

<activity
    android:name=".MainActivity"
    android:label="@string/title_activity_main"
    android:screenOrientation="landscape"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.HOME" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

代码:

@Override
public void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    super.onCreate(savedInstanceState);

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_main); 
    myLayout = (LinearLayout) findViewById(R.id.myLayout);
    myLayout.setBackgroundResource(R.drawable.bgfinal);

    createMainView();
}

@Override
public void onAttachedToWindow()
{
    this.getWindow().setType(WindowManager.LayoutParams.FLAG_FULLSCREEN); 

    super.onAttachedToWindow(); 
}

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    return false;
}

public void createMainView()
{
    LinearLayout HomePage = new LinearLayout(this);

    HomePage.setOrientation(LinearLayout.VERTICAL);

    HomePage.setLayoutParams(new LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    myLayout.addView(HomePage);
    TextView name = new TextView(this); 

    name.setGravity(Gravity.CENTER);
    name.setMinHeight(46);
    HomePage.addView(name);
    LinearLayout HomePageHorLayOut = new LinearLayout(this);
    HomePageHorLayOut.setOrientation(LinearLayout.HORIZONTAL);

    HomePageHorLayOut.setLayoutParams(new LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    HomePage.addView(HomePageHorLayOut);

    TextView name1 = new TextView(this);    

    name1.setGravity(Gravity.CENTER);
    name1.setText("     ");
    name1.setWidth(274);
    HomePageHorLayOut.addView(name1);

    final Button PIBtn=new Button(this);
    PIBtn.setBackgroundResource(R.drawable.pilatest);
    PIBtn.setLayoutParams(new LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    HomePageHorLayOut.addView(PIBtn); 
    PIBtn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            startActivity(new Intent(android.provider.Settings.ACTION_DATE_SETTINGS));
        }
    });
}

在这种情况下,无论何时启动应用程序,屏幕都没有任何软键,但每当按下按钮时,点火将使用户进入时间设置框架,即使我们返回到软键也不会隐藏软键应用程序。

我发现,几乎同样的问题有already been reported,但我已经尝试过这个答案,但结果是一样的。

在从设置中返回主应用程序时是否有隐藏软键的选项?

0 个答案:

没有答案