Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Widget-only app: Default Activity not found

Tags:

widget

I am creating a widget only application.

The project was on older SDK versions and it was OK.

Now when I downloaded the latest Android Studio bundle, it doesn't run my appilcation and it says:

Error running app: Default Activity not found

But I don't want any activity. I just want a simple widget, not any activity.

I know a lot of people has asked this question but believe me, non of them had the answer to my question.

p.s: If I add an activity and make it the default one by using the following code, it runs OK, but as I said I don't want any default activity. Is there any way?

<activity
    android:name=".MainActivity"
    android:label="MyAppName"             >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

Here is my manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.PerCalendar.perc"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="18" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
         <receiver android:name=".WidgetProvider" >
            <intent-filter>
                <!-- This widget provider receives broadcast with following action name or simply onUpdate of AppWidgetProvider is called -->
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
            </intent-filter>
            <!-- linking up xml file of appwidget-provider to AppWidgetProvider -->
            <meta-data
                android:name="android.appwidget.provider"
                android:resource="@xml/widget_info" />
        </receiver>

        <service
            android:name=".WidgetService"
            android:permission="android.permission.BIND_REMOTEVIEWS" />
    </application>

</manifest>
like image 568
SMahdiS Avatar asked Oct 19 '16 14:10

SMahdiS


1 Answers

The default action when installing and launching an app is starting the default activity. Since you do not explicitly launch an activity when starting a widget, just switch it off...

Select menu Run -> Edit Configurations. In the General tab for app, look for Launch Options and select Nothing instead of Default Activity.

This option got lost with one of the latest updates/migrations provided for the Android Studio.

like image 70
Ramo Avatar answered Nov 05 '22 12:11

Ramo