I created an abstract Activity which extends the android.app.Activity. Then I created an activity extending my abstract one. [1]
Everything is fine with ant, but eclipse showed an error in the manifest saying that my activiy did not exists, so I regenerate the class files and the error in the manifest is gone. But now eclipse shows an error at the root of my project and don't want to compile.
I precise that the activity is working fine in a device builded with ant. I tried to "Fix Project Properties" as well. I can't declare the abstract activity because of it's abstract.
Anybody already saw this bug ?
Thanks
[1] Here is a little schematic
android.app.Activity -> abstract ActivityNet -> MyActivity
This is a common bug/behaviour of Eclipse.
To eliminate it click on the "Problems" icon (right bottom corner but it depends on your prospective)
Right click on the error line and then delete it.
The error should be gone away now
Related
I moved the NavigationTabbedActivity from one project to another, but I'm getting this error:
setSupportActionBar method cannot be found.
I've tried replacing the import widget.toolbar with import android.support.v7.widget.Toolbar; but it doesn't solve the problem.
Actually it needs the class to extend Activity but in my case the class already extends CustomActivity which in turn extends the default AndroidActivity, I tried extending customActivity with AppCombatActivity but it didn't work either. Is this error because I copied the file? Where am i wrong?
Ok while copying the file i forgot to add appcompat in the manifest file. so add the AppCompatActivity in the manifest file ie)
compile 'com.android.support:appcompat-v7:22.+'
and extended the custom activity to AppCompatActivity , and resynced the project , that solved the problem , thanks for your suggestions :)
Based on the small amount of information that was given I will try and provide a answer.
First of, when you copy a file over to a new project the activity doesn't exist in yourManifest.xml so make sure you declare it in your manifest.
You would also have to copy the layout file from the previous project or change it in your new one.
The next thing is the old project name will still be at the top and needs to be changed to the new project name.
My best advice would be to remove all the imports at the top and import everything again to make sure all the classes and everything is imported correctly.
Currently working on Android Studio, I accidentally placed one of my activities as an inner class of another activity instead of transferring to the package. Now I can't seem to find that activity. How do I retrieve it?
So I am using BaseGameUtils to try and get Google Games to sign in. Now I have changed my activity, but I am getting some compile errors with setContentView() or anything else that uses the base activity. This is what it looks like,
Error image:
Unused Activity/Import:
Any advice anyone?
BaseGameActivity extends LoaderActivity. And, LoaderActivity extends Activity.
Therefore, If you already imported BaseGameActivity, you don't need to import android.app.Activity.
If you using Eclipse, just press [Ctrl + Shift + O] to remove useless imported files.
If you are using BaseGameActivity, you should override onSetContentView() instead of onCreate() and you can use this.setContentView() inside it.
After the ADT update in eclipse whenever I create a new project for android a default fragment activity is created. How to get to create simple activity always?
I don't want to downgrade the ADT.
Is this possible? any work around?
The latest ADT plugins are made in such a way that if you create any simple project you will always get the FragmentActivity not a simple Activity. And you can not change it.
In new ADT itself there is Blank Activity that is defined with an actionbar and optional navigational elements such as tabs or horizontal swipe.
If you want to create simple activity in your project then you can simply create class and extends Activity into it, this is the only way now. Or you can change the Fragment with Activity simply by changing code only.
As an Activity is simply a Java class, just accept the defaults the ADT gives you during the initial creation of your project. Create your project, then manually:
1. Delete all the class and layout files in your project.
2. Create your Java class files extending Activity (in your desired packages).
3. Create XML layout files (in the res/layout folder).
4. 'Wire-up' your Java class files and XML layout files using setContentView(R.layout.YOUR_LAYOUT_ID) in the onCreate() methods.
5. Done!
EDIT
Remember to Register your Activities in the Manifest manually as well.
I have copied an activity class from the internet : get user input
When I had the activity class inside the project, as a class file - it worked fine.
When I inserted the class +layout file into a different project (my dialogs.jar file) I could not start the activity.
The activity (TextEntryActivity) is under "com.xyz.dialogs"
My project is under "com.xyz.thisproject"
First I got the "activity class not found" error:
"AndroidRuntime(487): android.content.ActivityNotFoundException: Unable to find explicit activity class ..."
Then I read in an article that I should insert the startActivityForResult into a try/catch and I did.
The result is :
Activity is not shown
onActivityResult is fired without any action from the user
Notes:
I put the activity in both manifests (first only in jar,then in my project, then both)
I have another class (not activity!) in that JAR file and its working fine (a OK only dialog I build with dialog builder)
My questions are:
Is it at all possible to put an activity in an external library ?
Is it ok that that the layout file is in the jar (its only a textbox with two commands ok/cancel)
Where should I declare the activity (which manifest or both?)
How should I declare the activity (I saw samples with "ActivityName" and some other samples with ".ActivityName" where should I use what method...)
Thanks in advance
Guy
I have at least a workaround:
Make an Eclipse library project with your activity (there is an is-library property in the Android properties of an Android project) and make your second project use the library project. Here is more information on that topic: http://developer.android.com/guide/developing/projects/projects-eclipse.html
Then subclass your activity and declare the subclass in the manifest. This works around the package issue.