Extends Service and Implements Activity in the same class || Android

0

I'm trying to make an Android app that hides both the notification bar and the action bar (back to the start, etc), so I had thought about creating a service that hides the action bar because the notification bar does not I have a problem but when creating it I am forced to use both Service and Activity , this gives me the error in Activity :

  

Interface expected here

my code:

import android.app.Activity;
import android.app.Service;
import android.content.Intent;
import android.os.Build;
import android.os.IBinder;
import android.support.annotation.RequiresApi;

import android.view.View;

public class FirstService extends Service implements Activity{


    @Override
    public IBinder onBind(Intent arg0) {
        return null;
    }

    @RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)

    public void onStart(Intent intent, int startId) {
        super.onStart(intent, startId);

        View view = findViewById(R.id.activity_main);
        view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);


        this.stopSelf();
    }

    public void onDestroy() {
        super.onDestroy();

    }

}

Thanks for your help.

    
asked by Juanma M 25.01.2017 в 15:41
source

1 answer

2

To prevent the notification bar and the action menu from leaving, you can directly change the theme of your app in AndroidManifest.xml to force it to appear in full screen:

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

Or change the parent of your theme in styles.xml :

<style name="AppTheme" parent="Theme.NoTitleBar.Fullscreen">
</style>

And apply it in the following way in the xml of your Activity :

android:theme="@style/AppTheme"

Or use this code in the onCreate of your Activity:

@Override
public void onCreate(android.os.Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.main);
}
    
answered by 25.01.2017 / 15:56
source