1

I am coding an app that has to run from a service to enable continuous video streaming in the background. I tried implementing a navigation drawer into it and the sliding menu can even be opened via sliding your finger from the edge of the screen, however it cannot be toggled via openDrawer(...) or closeDrawer(...) and the sliding menu also does not open correctly. Rather than having the menu that pops up, the list view just slowly drags behind your finger and also cannot be hidden completely again. This is the code for the service:

public int onStartCommand(Intent intent, int flags, int startId) {
     super.onStartCommand(intent, flags, startId);
     wm = (WindowManager) getSystemService(WINDOW_SERVICE);
     params = new WindowManager.LayoutParams(width, height,
                    WindowManager.LayoutParams.TYPE_PRIORITY_PHONE, 8, -3);


     layout = (android.support.v4.widget.DrawerLayout) layoutInflater
            .inflate(R.layout.recording_service, null);

     leftDrawer = (ListView) layout.findViewById(R.id.left_drawer);


     adapter = new StableArrayAdapter(this, preferences.getString(
                COUNTRYCODE, getApplicationContext().getResources()
                        .getConfiguration().locale.getCountry()));

     leftDrawer.setAdapter(adapter);

     wm.addView(layout, params);
     return START_STICKY;
  }

and here is the xml:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@null"
    android:theme="@android:style/Theme.NoTitleBar"
    tools:context=".MainActivity" >

    <SurfaceView
        android:id="@+id/surfaceview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >
    </SurfaceView>


</RelativeLayout>

<ListView
    android:id="@+id/left_drawer"
    android:layout_width="240dp"
    android:layout_height="match_parent"
    android:layout_gravity="end"
    android:background="#111"
    android:choiceMode="singleChoice"
    android:divider="@android:color/transparent"
    android:dividerHeight="0dp" />

Many thanks in advance for any help.

0 Answers0