Eclipse loads separate activities instead of application - android

I'm using Eclipse and android SDK (with ADT Plugin), I don't know if it's some kind of configuration issue or it's some code problem. Whenever I load an app that I made from scratch (this means not using another existing code or one sample from the library) to my device or run it on the emulator, the entire app will load as "separate" apps, which are the activities. For example, if the app is named "Hello world" and it has two activities, "MainActivity" and "SecondaryActivity", both of them will show up on the device with their names as app names and sharing the app icon on the menu. Now, if I go to settings, "Hello World" appears as an application, now behaving again like it should. This doesn't affect the operation of the app, however, it's annoying to have more than 1 icon launching the same app. The problem is that, when i first used eclipse, this was not happening.
Just in case it helps, I've already re-installed the entire android SDK and the ADT plugin, as well, I tried using 3 different Eclipse versions (classic, EE, and Java developers), none of them seem to work, even though, in the Graphical Layout for any activity, the name of the app is showed in the bar with the app's icon, but running on the emulator or a real device it shows the activity's name there instead. I've looked everywhere and I haven't solved the problem.
Thanks!

Check your manifest to see if more than one activity has this:
<category android:name="android.intent.category.LAUNCHER" />

The answer I found for the above problem is, replace category.LAUNCHER to category.EMBED in all the activities apart from the MainActivity in your manifest file.

Related

How to start developing app for Google Glass?

I am working on a Google glass Android app. I have installed the glass development kit (GDK) in Android SDK. Now I created a glass project using Android Studio (Version 3.3.2). The newly created project is showing an error "Default Activity not found" in run->edit configuration.
Please refer the screenshot for the error.
1.
And 2. By clicking run->Edit Configuration in menu.
I have searched a lot on Google and found many articles regarding the same. All are suggested to set the edit configurations option like below.
Module: app
Package: Deploy default APK
Activity: Launch default Activity
Target Device: USB Device
I did the same, but no one is working for me. After spending the whole day to make it work, I came here. This error is due to the Launcher activity, because there is no launcher activity in Google glass project instead it uses Voice Trigger intent filter. It is similar to wearable apps they also don't have the launcher activity.
Android Studio won't let you use a standard run configuration without specifying a launcher in the manifest.
You could try using the gradle command line instead:
./gradlew installDebug
In case you haven't resolved the issue. I came across similar issue before, two ways worked for me:
Choose "Nothing" as the option. You will be able to run the app manually on the Glass, but your debugger won't work straight away. You have to manually attach the debugger to the process. You may also have to use logcat if there is a bug in the launching process.
Specify an activity (whichever is associated with voice trigger).
Also, I noticed that you created the app using Kotlin. Kotlin activity didn't work in my case, throwing exceptions associated with nullable var when resuming the activity. Non-activity classes worked fine. Please let me know if Kotlin activity worked in your case.

Hide application shortcut

I am trying to make an application of which I am trying to hide the launcher shortcut. The reason for this is so I could use this apps as a module / extension for another app without it being visible or cluttering the launcher environment (ie. having this app on your phone will unlock partial functionality in another app). I have been looking into how to do this for a while now, but I can't find a proper solution.
I have read a 'solution' to this issue that tells me to remove <category android:name="android.intent.category.LAUNCHER" /> from the AndroidManifest.xml file. This however results in Android Studio not being able to build or run the app at all, giving me an error that says Default Activity not found (I have tried this with a fresh project and an empty activity).
I am trying to develop this app on my personal device which is a Huawei P9 Lite, running android 6.0
Is there a way to do this?
EDIT
I've read somewhere that Google has removed the ability to uninstall shortcuts since android 6.0. Although it doesn't really say anything about hiding shortcuts for your application, I went ahead and assumed it's part of the same security fix.
Is there a way to do this for the newest platform versions?
I have read a 'solution' to this issue that tells me to remove from the AndroidManifest.xml file.
That is the correct answer.
This however results in Android Studio not being able to build or run the app at all, giving me an error that says Default Activity not found (I have tried this with a fresh project and an empty activity).
Well, it may not make sense to run it. After all, you say that this app is a plugin to some other app. In many cases, a plugin itself cannot run independently (e.g., you cannot run a browser plugin except via the hosting browser).
That being said, you can edit your run configuration via Run > Edit Configurations, and choose what you want to have happen when you run the module:
The run configuration for an app module defaults to "Default Activity", but you can choose something else (e.g., "Specific Activity").
I've read somewhere that Google has removed the ability to uninstall shortcuts since android 6.0.
That answer is unrelated to your question.

Example NetworkUsage Android Code Crashes On Startup?

I am trying to run the example application in the networkusage.zip file on the Android Developers website (location: http://developer.android.com/training/basics/network-ops/index.html).
I have not made any changes to the code whatsoever. However, it crashes immediately on startup. I have tried setting a breakpoint in the onCreate method of the main activity, but it never gets there....just crashes right away.
I am just starting with Android, but I been able to complete other training sessions and run other example apps, so I believe my configuration works. I am running Windows 7, with Eclipse Juno and the very latest JDK and Android SDK/ADT (both downloaded about a week ago).
I am using an emulator targeting Android 4.1 (API 16).
The emulator shows a messages that says Unfortunately, NetWork Usage has stopped working.
Any help would be greatly appreciated!!
In AndroidManifest.xml file, for this project, substitute absolute android:name for NetworkActivity with relative one.
In other words, change this line:
android:name="com.example.networkusage.NetworkActivity"
to look like this:
android:name=".NetworkActivity"
The problem was that NetworkActivity is not in com.example.networkusage (as was in AndroidManifest.xml file), but in com.example.android.networkusage package. Thus, Android couldn't find the class on runtime.

on click of shortcut on homescreen launching from spalsh screen in android

I reated configuration in mainfest file as follows
shortcut is created on homescreen, but the problem is when i click on this it is not retaining the state correctly, it is starting from splash screen. when i launch an app from all apps it is retaining the state correctly.
Myapp-->splashscreen-->Activity1-->Activity2-->click home-->click shortcuticon-->splashscreen
Myapp-->splashscreen-->Activity1-->Activity2-->click home-->-->click menu-->all apps-->click shortcuticon-->Activity2
I'm going to assume that you started the app initially (the first time) from an IDE (like Eclipse or IntelliJ) or after installing it using the installer (from the market or browser or clicking on APK in file browser). If so, this is a known bug in Android (see http://code.google.com/p/android/issues/detail?id=26658 ). Many people have struggled for days chasing this problem :-(
A simple workaround for this problem can be found at http://code.google.com/p/android/issues/detail?id=2373#c21
To verify this is your problem, don't start it from the IDE or installer. Simply install the app and then go start it from the list of available applications.
If the shortcut is created programmatically then your app wont resume because you have specified an activity for shortcut intent,
To solve this, have a look at the the answer here

When an app runs, the other one is removed

I have two app's projects in two different Eclipse's workspaces. When I run one of the apps, the other is removed from my phone and I can't figure out why. I have already tried cleaning up each project (Eclipse->Project->Clean...) because I suspected that it was some kind of Eclipse's mess, but it didn't work.
Any suggestions?
Have you named them differently in your manifest? If they share the same properties, then the installer could mistake one for the other, and remove the "old" one when installing the new one.

Categories

Resources