SmartWatch 2 app without Smart Connect - android

I have a Sony Smartwatch 2 and I am currently trying to develop an app for it on Android Studio, but I am facing a difficulty:
I want the user to be able to choose if he wants or not to use the smartwatch option, that means I dont want to have my app started only by the "Smart Connect" app. I would like to Launch my app as a normal app and, once the app is running, give the user the possibility of using the Smartwatch.
If I use one of Sony's sample projects as a base to my app, it automatically gets installed on "Smart Connect". By trying to add the Smart Extension Utils and Smart Extension API to my "common" app, I can't get it to work with the smartwatch 2.
How can I do it?

If I am understanding your question correctly you can still have your app launch as a normal app by creating a main activity and setting it in your manifest as the default launcher.
So for instance create your java class:
com.yourapp.package/MainActivity
Then update your manifest file:
<activity android:name=".MainActivity" 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

Different activities for different device's type

I have an application for smartphones. In my AndroidManifest.xml file placed activity with special intent-filter
<activity
android:name=".feature.splashscreen.SplashScreenVm"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Now, I need to launch my application on wearable devices. Obviously, default activity for wearable device should be WearableActivity.class. How to configure my AndroidManifest.xml to launch different activities depending on device's type? Or maybe it should be handled not by manifest?
As far as i know, for wearable devices(e.g watches), you need to have a different apk.
It currently is not possible to create a single APK that works on a phone and watch.
for more info you can check :
https://developer.android.com/training/wearables/apps/packaging.html
EDIT:
I also found a tutorial about how to do what you plan;
https://medium.com/#manuelvicnt/android-wear-add-a-wear-app-to-your-already-existing-android-app-2a668442dd0a
It is true the apks are different. I would advise if you to build a second app for wearables with limited functionality or only the important functions that are in your smartphone app. Take note wearable devices have limited screen real estate so you might want to just use it for something such as just notifications.

Cant upload my app with Android Studio

I tried to upload a testing app (just blank page) to my phone.
I can see my phone in the list when I press run and there is no new app in my phone and nothing apears there.
why?
thank you.
Firstly, if you app is failing to compile, you will need to check Android Studio for compilation errors. These can be found in the Messages view.
To put your app on a device, your test device will need USB Debugging enabled on it. Please see this answer for more information on how to turn it on should you have missed this step.
If the app is compiling but isn't starting, ensure that you have the following intent-filter within your main activity's definition in your AndroidManifest.xml file.
<activity
android:name=".YourMainActivityName"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
This intent filter is how the Android OS works out which activity to launch when the app is freshly opened. Without this filter, no activity will start.

Separate launcher icon for companion configuration activity of a watch face (Android Wear)

I implemented a watch face with a configuration activity on the mobile device. The configuration activity works fine when launched from within the Android Wear app.
However, I'd like to create an extra icon that launches the configuration activity like a normal app, from outside Android Wear. When I simply implement the activity as a normal app in AndroidManifest, like below, it fails to communicate with the watch.
Ideally, the extra launcher should start the configuration activity together with the Android Wear app, if it's not running already.
<activity
android:label="Companion Configuration"
android:name=".ConfigActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
It's nothing to do with the launcher icon - or really anything on the phone side.
What you need is for your Wear app to launch when data is changed in your phone-side configuration activity, and that's all set up in the wearable app. It's well documented at https://developer.android.com/training/wearables/data-layer/events.html#Listen
In your case (since your watch app isn't running yet when the phone Activity is launched), you'll probably want to subclass WearableListenerService. This will get run by the system when data is changed on the phone, and you can do whatever is appropriate for your app when that happens.
I got this working by using the Wearable.DataApi instead of the Wearable.MessageApi
I had been using the Wearable.MessageApi to update watch from phone and that requires a peerid which i guess is generated by the wear app. I put a if/then statement to check if peerid is null and if so use the DataApi instead and works from inside the wear app and from app drawer

Android wear app in development stage does not appear in watch launcher

When I run my developed android wear app via Android studio, it normally installs in my watch and can be later launched via wear launcher. Not sure what could happen, my latest project does not appear as icon in the launcher anymore, despite I can see the app being launched and fully functional, but after the ambient mode, when the app is moved to the background, I cannot relaunch from the wear. The only way would be to launch it from Android Studio again. The app icon was deleted from watch and I cannot figure out why!
When I check the list of packages in the phone via ADB, I can see it listed, but it never appears among installed apps in the wear, and it did few days ago.
I have LG G Watch R with Android 5.1.1, Android Wear 1.3.0.2166028, and Android Studio 1.5.0/141.2422023
This is what I figured out by trying different manifest setups:
When providing the intent filter to start your main activity in the wear manifest as a combination of action.Main and action.TRACK category with mime type /running, the activity will not register in the launcher with an icon, only voice action OK GOOGLE START RUNNING will launch the activity.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="vnd.google.fitness.TRACK"/>
<data android:mimeType="vnd.google.fitness.activity/running"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
To get the icon back to the launcher I had to make a compromise of loosing the ability to start the main activity with the voice launcher.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /></intent-filter>

How to open the application from my android application with no launcher

I have 3 android applications. One main application call other 2 applications (main application will be interface for other 2 applications). I would like to have only one icon of this main app. I have 3 applications they can be downloaded separately. Now I need the other applications to check if the main application is installed. If not, download and install main app. But how can I do that, if the secondary applications haven't got LAUNCHER ? Is there any way to do install main app from app without launcher ?
Main app has android manifest:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Secondary app has manifest (because do not want icon)
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
Yes I know how to use code in app where is launcher to check app is installed, but dont want how to operate with, when the launcher is not.
if (installed==false) {
Intent promptInstall = new Intent(Intent.ACTION_VIEW)
.setData(Uri.parse("https://play.google.com......))
.setType("application/vnd.android.package-archive");
startActivity(promptInstall);
Or second question: is it possible to install app with launcher and then uninstall/hide icon of this app ? Let's say simple I will install all aplications with launcher and then after installation and settings hide icon of app, so that stay only icon of main application.
It looks strange for me, there is not any simple way to do that, simple set if icon will be visible or not. The same as you install software on Windows and you can set during installation if icon will be visible on desktop.

Categories

Resources