How can I Integrate my Widget Application into my another Application - android

Hi guy's Please See the question asked on this link[ Integration of my widget with my application ][1]
[1]:
My problem is exactly same as the question asked on this link.
Very first I have tried this Ans=>
1]
i) Turn the Widget project into a Library project : properties -> Android -> and tick Is Library
ii) Go to the original project and import the Widget project : properties -> Android -> Add
iii)In the original project's Manifest, add the text between the (...) , including and , into the (...)
But this didn't work for me.. Then I tried second ans i.e.---
2] Copy all code from one package to 2nd one and merge AndroidManifest.xml ...
But in this case My both application i.e. widget App and Another app has MainActivity.. So there is ambiguity between them.. ! Please help..!

Finally I've solved my problem, what I did is--
I have copied all Activities, Classes and Services form my widget app to my another app.
After that I have merged the both Manifest files (One from widget app. and one from my another app) into my another app, so that it is a single Manifest file. And the main problem was my widget app and another app both had the activity with same name i.e. MainActivity, so to resolve this problem I've just renamed MainActivity from my widget app to StartActivity, and problem got solved, now application is running fine.!

Related

Create new android project with out Fragment activity in eclipse

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.

Fragment Layout Name

I have been using Android ADT for a few weeks now and i used to normally create new activities by going to:File>New>Other>Android>Android_Activity>Blank_Activity. However after updating my 'Android SDK Tools' & 'Android SDK Platform Tools' today , its now showing a new option when I'm trying to create an activity.
When I select new blank activity and click next , its then showing a new form that i have to fill in which is titled as 'Fragment Layout Name'. Why has this suddenly appeared and does anyone know why I'm being forced to create a fragment layout as i don't want to even use this. I also remember one of my friends saying that he updated his SDK about a week ago and he stated that he had the same problem. Shall i just remove the fragment in the XML document once its loaded or is there a way to disable this so i wont have to go through this every-time.
The templates of files produced by "New ..." wizard have changed lately. Now you are enforced to create a new Activity with a Fragment placeholder attached. Guess that's the way the developers enforce people to build UI based on Fragments :)
There are a few workarounds for your problem:
1) Just delete fragment layout in your resources; delete the placeholder fragment in your Activity code and all the relevant code (FragmentManager etc); change activity layout from FrameLayout to anything you like.
2) Follow the recipe proposed in this answer
3) Don't. Ever. Use. Wizards. It is much better to create a new class and write extends Activity (or Fragment, Service, etc), than to create a template and waste your precious time changing it to your needs. And it helps to understand the lifecycle of components, too.

Eclipse Android Custom Activity Class File (subbing for autogen activity file for new project)

When I create a "New Android Application Project," I would like Eclipse to proceed with its normal actions with (at least) one customization.
I want Eclipse to create the new Activity.Class file using fuller #Overrides rather than just the onCreate(), such as also providing onStart(), onResume(), onPause(), onRestart(), and so on.
In other words, I want a more verbose Activity.Class file generated than is already done by Eclipse.
Going further, I would also like Eclipse to add my own inner classes - if that is not asking too much.
In short, is there a template in Eclipse that I can tailor for this customization?
I am not aware of a way to accomplish this within the "New Android Application Project Dialog", but you add additional overrides to each activity yourself by clicking the Source dropdown menu, then Override/Implement methods..., and then select each method you would like to override.
I'm not sure what you mean by add your own inner classes. You can do this easily yourself, I'm not sure what additional functionality Eclipse could provide.
This might answer your question. There's a templates directory in your Android SDK where you can add or alter the XML templates.
Good luck,
Bp

widgets disappear after updating app, using library

I have 2 versions of an app, free and paid, but have been maintaining the code separately. I've finally moved the code into a library referenced by both to make maintaining the code easier.
I found that changing the AppwidgetProvider caused the launcher to delete any existing widgets, so I moved those classes back out of the library to keep the provider the same so users don't have to recreate their widgets. The launcher no longer deletes the widgets, but instead, they simply don't appear after updating.
If I call AppWidgetManager.getAppWidgetIds for the componentname, as it's always been, the appwidgetid is still there. The appwidgetprovider and service still get called to update the widget, and /data/system/appwidgets.xml still shows the widget, but the launcher never displays it.
It's not that it's invisible, as long pressing in the widget location brings up the wallpaper chooser. I can create new widgets just fine, but I don't want to frustrate users by asking them to recreate their widgets. The logs don't show any errors thrown by the launcher or AppwidgetService.
Any ideas why the widget stops rendering after updating? It's somehow related to moving most of the code into a separate library. Thanks!
Edit: I'm testing on an emulator, api level 15, stock launcher
OK, I found a solution, but I feel sick for what it is...
After reading about how classes declared in the manifest should never change, I went and creating each class in the manifest as a class in the app, extending the corresponding class in the library. Then, I had to change every Intent to include the correct class, using forName. So, an example of this scenario is:
app package: com.sample.package
activity: MyActivity
library: com.sample.package.core
activity: MyActivity
There's a MyActivity in the app, and a MyActivity in the library. The MyActivity in the app simply extends com.sample.package.core.MyActivity.
Then, any occurrence of...
new Intent(context, MyActivity.class)
...in the library must become...
new Intent(context, Class.forName(context.getPackageName() + "." + MyActivity.class.getSimpleName());
If there's a way to do this through the manifest, please let me know!

android activity in jar library

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.

Categories

Resources