Eclipse- creating new Activity - android

I have problem when I create a new Android project. I fill in the name of the app and the package name, then I go to the next scrren and set the icon. On the following scrren I select Blank activity and hit next when this screen appears:
I enter everything, but i donť know what to do with Hierarchical Parent. A few days ago it worked perfectly, but now when I chose something from list on the left, and create activity, eclipse unless I wrote something says it's wrong.
Can anyone help me?

For an Activity set it to android.app.activity.

I got the same problem like yours. After a day, I found the way.
It's very simple. re install the ADT Plugin:
In Eclipse, Help > Install New Software....
Click Add, in the top-right corner.
Enter "ADT Plugin" for the Name and URL = http://dl-ssl.google.com/android/eclipse/
Then just enter until finish
For the full tutorial how to instal ADT Plugin you can look at:
http://developer.android.com/sdk/installing/installing-adt.html

Your error concerns the name of the activity verify the project build sdk
the hierarchical parent activity is used normally to provide a default implementation for the UP button

1.Copy your Package Name, then past to "Hierarchical Parent" Field.
(any words to skip this step)
2.AndroidManifest.xml need an "android.intent.action.MAIN" for start.
Add follow source code
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
like this:
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".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>
</application>

Platform-tools version 14 has this problem, but not version 13.
http://dl-ssl.google.com/android/repository/platform-tools_r13-linux.zip
I backed up my current (problematic) /android-sdk/platform tools, deleted the old folder and replaced it with ver 13, started eclipse, reset the android-sdk path (windows>preferences>android, don't forget to click "apply") and recreated my AVD.
Version 13 also has the heirarchical parent text box, but it's optional.

The problem is a bug with the Application Wizard... which tries to integrate the Activity Wizard within itself. The problem is that the integrated Activity Wizard doesn't work correctly without there being an existing project.
Therefore, an easy solution to this problem is from the Project Wizard, just create a basic main activity with "none" for navigation type and click "finish". Then once the project has been created, use the Activity Wizard to create your desired main Activity.
As a bonus, the Activity Wizard will even refactor the code to use this new Activity as your main Activity!

Related

How to choose an activity as a starter activity while launching an app?

I come up with a strange problem while trying to set "SignUpActivity" as my starter activity. I tried different ways but either I am getting an error or "mainActivity" is popping up as a starter activity.
My "AndroidManifest.xml" file has the following code.
<activity
android:name=".SignUpActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity" />
the above code gives me the error as shown in image
As the error states activity must be exported or contain an intent-filter
so, I did
<activity
android:name=".MainActivity"
android:exported="true"/>
and also tried adding intent-filter to activity. Of course, these methods make error go away but my app starts with MainActivity, not with SignUpActivity. What should I do to slove this issue?
Your AndroidManifest.xml is set correctly, check your run/debug configuration is set to 'App', not 'MainActvity'
If the 'App' configuration is missing - you will need to add it by first selecting 'Edit Confurations'
There are similar posts about this error msg.
Check the run configuration , probably you need to edit the app configuration and choose it to run.
As guided by #Eric I selected an option "app" from the run configuration which solved my problem. Previously, somehow it was set to MainActivity which was causing the issue. I have attached an image to demonstrate the solution for future readers.

Default activity not found in my android studio

I have created a new project in android studio and when i am trying to run it ,it is saying default activity not found.i have checked my manifest file this does not contain any problem.
there is a Red X Mark android studio application while running
Exit Android Studio.
Go to path > C:\Users\YOUR_WINDOW_USER_NAME\.AndroidStudio3.3\system
Remove /caches folder.
Make sure
you have defined Launcher activity in Manifest file for
one Activity
you have set the default activity from Configurations
you have set the selected activity from Configurations.
There is a work around to make it work that worked for me.
1- Select Edit Configurations from the drop down next to run button.
2- Under launch options > Launch select Specified activity.
3- Another field "Activity" will appear select your default activity.
4- Click OK and sync project with gradle files and it should work.
two Method for solving this problem
Method 1.make sure that default activity is define in your manifest
Method 2. even default activity is define but not solved than go to your manifest file click on merged Manifest at bottom left side of your manifest file and you will see the side drawer menu of your manifest file you will see the error and from there you can solved your error by click on suggestion.
Check the manifest file and under the activity tags make sure it has:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".Activity_name Here"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Make sure that the line containing the action android:name= "android.intent.action.MAIN"
is included in the activity tag of the application.
Also make sure that activity name is corresponding to the android:name of the activity.
Try to check this code..
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
Check whether your Launcher activity intent filter has this
tools:node="remove"
If yes, remove it and error will be resolved. This piece of code will be used when we are having flavors in our project structure, in-order to remove a Launcher activity.
Else, Two launcher icons will be installed.
i have resolved this issue by changing the location of android studio from program files to program filesx86

MyFirstApp installed on emulator but can't launch it

I'm going through the Android 'Building Your First App' tutorial and have gotten stuck trying to run the app. I created the app and emulator with Eclipse (Juno Build id: 20120920-0800 on OS X, default installation. The Android SDK, etc. was updated today).
The app appears to be installed on the emulator. I.e. 'Home -> Menu -> Manage Apps' lists it and it's App info looks ok. (Total=24.00KB, App=24.00KB, USN storage app=0.00B, ...).
However, it does not appear in the apps launch list (i.e. the screen with 'API Demos', 'Browser', etc.
Is there some other way to launch it? Is there something I have to do to get it into the app list? Any help would be appreciated - this is driving me crazy.
thanks
In your manifest xml file you need to make sure that you have
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
in your activity definition. If you don't see your application in the launcher then it suggests you don't have "android.intent.category.LAUNCHER" set.
Your manifest file should have something like (this isn't a complete manifest)
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".MyActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
You can't just put the intent-filter lines in your manifest. If you double click the manifest it will open up. You get 2 methods to edit it, raw XML or using a basic interface. Personally I think you're better off with the raw interface. Look below the window that opens when you double click the manifest, you'll see some tabs like Manifest, Application... the last on is AndroidManifest.xml - this is the raw xml. The first one is basic setup.
Don't forget to save your manifest file and do a clean and build then run it.

No launcher icon

I have an interesting problem - at least for me.
I don't want my application to have a launcher icon in the menu - I start it remotely and I don't want to show it up in the menu.
How can I solve that?
My idea is deleting the following from the manifest:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Would this solve my problem?
Delete that:
<category android:name="android.intent.category.LAUNCHER" />
And you won't have a launcher icon.
That's what i would do. This defines the gateway activity to your application and doesn't affect the functionality. If no activity has this filter, there won't be an icon to launch it manually, precisely what you want.
https://stackoverflow.com/a/13552763/6481542 is correct, but to address the Android Studio compilation issue noted in the comments, you need to modify the Run Configuration in Android Studio:
Go to Run -> Edit Configurations
Under Launch Options, change Launch from Default Activity to any of the other options. Using Specified Activity with one of your activities is a suitable approach.
This works with Android Studio 2.2.3.

When I install my apk I get an icon for every class in the project

I have a project in Eclipse with maybe 7 different classes that i open with Intent. The problem is when I install the .apk on my HTC phone I get an icon for every class. How do I make the project so it installs as one app only? /Johan Andersson
Exactly, as mreichelt said you have to remove this lines from each class declared on your Manifest except from the one you want to be the main Activity :D
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
If you only want one activity to be started from the launcher, just remove the intent filters for all other activities than your wanted one in your manifest. Read more here: http://developer.android.com/guide/topics/fundamentals.html#ifilters

Categories

Resources