tags:

views:

18

answers:

0

I'm trying to create an app that will change a setting when the user holds the search button. It seems that the combination of the WRITE_SETTINGS permission and the fact that the activity is launched from another application using the long press makes the parent task crash. For example, if I'm looking at Google Maps and hold the search button, the SearchButtonPopup does not appear and Google Maps crashes.

I tried taking the Theme.Dialog out, but it didn't make any difference. Removing the permission makes it robust again, no crashes, but I need the permission! Any fixes or workarounds?

These are my manifest and java files:

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="org.stathissideris.searchbuttonpopup" android:versionCode="1"
    android:versionName="1.0">
    <uses-sdk android:minSdkVersion="3" />
    <uses-permission android:name="android.permission.WRITE_SETTINGS" />

    <application android:icon="@drawable/logo" android:label="@string/app_name"
        android:debuggable="true" android:permission="android.permission.WRITE_SETTINGS">
        <activity android:name=".SearchButton" android:theme="@android:style/Theme.Dialog">
            <intent-filter>
                <action android:name="android.intent.action.SEARCH_LONG_PRESS" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
    </application>
</manifest>

SearchButton.java

package org.stathissideris.searchbuttonpopup;


import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

public class SearchButton extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.d("SearchButtonPopup", "search held");

    }
}