How to put widget and app in same apk? - android

I'm trying to put a widget and an app in the same apk.
Here's my manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.me.mywidget"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".settingsPage"
android:label="#string/app_name"
android:theme="#style/app_theme"
>
<intent-filter>
<action android:name="com.me.mywidget.SETTINGSPAGE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<receiver android:name="MyWidgetProvider" android:label="My Widgets">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="#layout/widget_info" />
</receiver>
<service android:name=".UpdateWidgetService"></service>
<activity android:name=".Test"></activity>
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-sdk android:minSdkVersion="7" />
</manifest>
How do I put an app and market in the same apk? I tried this and while it runs, the app does not show up in the app drawer.
Also, when I add android:name=".mywidgets" my widget crashes when I run it.
Also, I will be adding multiple sizes to the widget later on.

You need to add the intent filter for launcher to whichever activity you want to show in the launcher...
<category android:name="android.intent.category.LAUNCHER" />
So if .Test is your primary launching activity you would modify your manifest like below..
<activity android:name=".Test"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

Related

getting error No Launcher activity found! in creating a setting activity for a widget

in writing a widget and after i tried to add a setting activity for my widget , i got the error "No Launcher activity found!"
this is my AndroidManifest.xml :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.persianweather"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<receiver android:name="com.example.persianweather.Main" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<!-- This specifies the widget provider info -->
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/widget" />
</receiver>
<activity
android:name="com.example.persianweather.SettingActivity"
android:label="#string/title_activity_setting" >
<intent-filter >
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
</activity>
</application>
No Launcher activity found! means that you not mentioned any activity on launching the application. Try to add these lines in manifest. To specify these MAIN and LAUNCHER in the the intent filter for the activity you want to start on launch like:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Note: Multiple action tags in a single intent-filter tag will also cause the same error.
Make your SettingActivity as launcher activity, Only then you will be able to proceed further,
<activity
android:name="com.example.persianweather.SettingActivity"
android:label="#string/title_activity_setting" >
<intent-filter >
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

Eclipse showing No launcher Activity found

This is my android Manifest.xml.
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="uk.co.halfninja.wallpaper.parallax">
<uses-sdk android:minSdkVersion="7" />
<uses-feature android:name="android.software.live_wallpaper" />
<application
android:label="#string/app_name"
android:icon="#drawable/icon">
<service
android:label="#string/app_name"
android:name=".ParallaxWallpaper"
android:permission="android.permission.BIND_WALLPAPER">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="android.service.wallpaper" android:resource="#xml/wallpaper" />
</service>
<activity
android:label="#string/wallpaper_settings"
android:name=".ParallaxWallpaperSettings"
android:theme="#android:style/Theme.Black.NoTitleBar"
android:exported="true">
</activity>
</application>
</manifest>
Still Eclipse showing the result
ParallaxWallpaper] No Launcher activity found!
ParallaxWallpaper] The launch will only sync the application package on the device!
ParallaxWallpaper] Performing sync
ParallaxWallpaper] Automatic Target Mode: Unable to detect device compatibility. Please select a target device.
Please let me Know where am i doing the mistake, and what would be the solution...???
Move the intent-filter tag from service to activity
These lines should be in Activity tag
<application
android:label="#string/app_name"
android:icon="#drawable/icon">
<activity
android:label="#string/wallpaper_settings"
android:name=".ParallaxWallpaperSettings"
android:theme="#android:style/Theme.Black.NoTitleBar" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:label="#string/app_name"
android:name=".ParallaxWallpaper"
android:permission="android.permission.BIND_WALLPAPER">
</service>
<meta-data android:name="android.service.wallpaper" android:resource="#xml/wallpaper" />
</application>
make activity as launcher you have made service as launcher. like that
<activity
android:label="#string/wallpaper_settings"
android:name=".ParallaxWallpaperSettings"
android:theme="#android:style/Theme.Black.NoTitleBar"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

combining two eclipse android java applications

I'm trying to combine the functionality of BasicAccessoryDemo with AndroidWebServer (basically a USB=>Electronics interface with a simple web host app)
My java knowledge is limited at the moment and I'm running into some issues.
I tried combining the code into one project, but couldn't get it to work. I've read about adding one project to the other as a library.
Tell the BasicAccessoryDemo it's a library
Tell AndroidWebServer to include the BasicAccessoryDemo library
If I try to call a BasicAccessoryDemo method inside AndroidWebServer, I get the error 'accessoryManager cannot be resolved'. Which looks like there's no real connection between the apps?
Tried adding the BasicAccessoryDemo AndroidManifest.xml info to the AndroidWebServer manifest, but doesn't make a difference. Am I missing something? Sorry if this is a noob question, I've been trying to get this to work for a week now.
If anyone could point me in the right direction, that would be terrific!
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.varma.android.aws"
android:versionCode="1"
android:versionName="1.0"
android:installLocation="auto">
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-sdk android:targetSdkVersion="14" android:minSdkVersion="10"></uses-sdk>
<uses-permission android:name="android.permission.VIBRATE"></uses-permission>
<application
android:icon="#drawable/icon"
android:label="#string/app_name"
android:name="com.varma.android.aws.app.AWSApplication"
android:description="#string/app_desc" android:debuggable="true">
<activity
android:name="com.varma.android.aws.ui.AWSActivity"
android:label="#string/app_title">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.varma.android.aws.ui.AWSMessageActivity"
android:label="#string/message_title"
android:theme="#android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity
android:name="com.varma.android.aws.ui.AWSPreferenceActivity"
android:label="#string/preference_title">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<service android:name="com.varma.android.aws.service.HTTPService" />
<!-- this section from BasicAccessoryDemo -->
<activity
android:name="com.microchip.android.BasicAccessoryDemo.BasicAccessoryDemo"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<!-- <category android:name="android.intent.category.LAUNCHER" /> -->
</intent-filter>
<intent-filter>
<action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" />
</intent-filter>
<meta-data android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED"
android:resource="#xml/accessory_filter" />
</activity>
<uses-library android:name="com.android.future.usb.accessory" />
</application>

Various activities, various intents, failed at name app

I have some intents to execute different activities, my problem is that when I run the app in the device, eclipse install it with the name of the last activity. For example:
We have, three activities: 1 - 2 - 3. The first is the main activity (1), it name is Noow but I have an Intent to another activity (3) to get the location and return the data to (1). The app installed is named as getLocation (3) and it must have the name of the (1).
This is the manifiest xml file. Could someone help me with this? Thanks
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="victor.martin.noow"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="victor.martin.noow.SplashScreen"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="victor.martin.noow.LoginScreen"
android:label="#string/title_activity_login_screen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="victor.martin.noow.MainActivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="victor.martin.noow.getLocationActivity"
android:label="#string/getLocationActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
This is happening because the SDK will use the name of the activity having the LAUNCHER property:
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
The simplest solution would be to delete the LoginScreenActivity label and set it programatically. In this case the label provided in the tag will be used.
First of all there has to be one activity set as main activity i.e launcher activity. What you have done is set all activities as main which is incorrect in all terms of programming logic.
The activity with
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
gets the by default name, and by convention in your case after reading your xml the last activity got default name.

How to create a transparent activity? which will start after every 5 minutes.And the background should remain what it was

I am creating an application which will call a new transparent activity to launch every 5 minutes.whether the phone is locked or not.
Every thing is working fine.But the problem is when this activity is started,it will start on
a MAIN Launcher activity.
I want to show that activity on Desktop, menu or whatever user is in.
How can i do this?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.spec.test"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".BroadCastDemoActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".TransparentActivity"
android:label="Transparent"
android:theme="#style/YourTheme">
</activity>
<receiver android:name="MyBroadCastReceiver"></receiver>
<service android:name="MyService"></service>
</application>
<uses-permission android:name="android.permission.VIBRATE"></uses-permission>
<uses-permission android:name="DEVICE_POWER"></uses-permission>
<uses-permission android:name="android.permission.WAKE_LOCK" />
</manifest>
You TransparentActivity needs an <intent-filter> change your TransparentActivity part in the manifest to this
<activity android:name=".TransparentActivity"
android:label="Transparent"
android:theme="#style/YourTheme">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Or to this if you want the transparent activity to start when you start the application from the users homescreen.
<activity android:name=".TransparentActivity"
android:label="Transparent"
android:theme="#style/YourTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

Categories

Resources