Reputation: 12989
I've been developing (hacking together) an app widget, which is working OK now. I had always intended to implement an associated app, so that the user would have a choice between running the app or adding the widget (or both).
Till now, I've sidelined the app by adding a Toast in the main Activity's onCreate() method, and adding a finish() at the end of onCreate() so that when I run my project from within Android Studio, on my device all I see is a quick Toast, with no pesky Activity view showing up.
Now I'm ready to have a go at the app, so I took out the Toast and removed the finish(), but I find that the simple "Hello World" TextView (which is put there as a placeholder when creating the project) no longer shows, and instead the app just hangs when I try to run it.
I have literally no clue why this is happening, but suspect it related to the associated widget stuff.
My onCreate() method is still super simple:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
}
And the activity_my view is likewise simple (still the stock "hello world" example):
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MyActivity">
<TextView
android:text="@string/hello_world"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
Any idea where I should go from here?
Upvotes: 0
Views: 77
Reputation: 12989
D'oh. Hopefully I got here quick enough to avoid wasting anyone else's time, but I just realised what else I did to prevent the main activity's view from showing whilst developing the widget...
I added the following line to my AndroidManifest in the main activity's section:
android:theme="@android:style/Theme.NoDisplay">
Once I removed that, things are back to normal.
But maybe this will help someone equally as stupid as me in the future. The annoying thing is that I even wrote a note to myself in the code to remind me to take out the above line from the Manifest file when I eventually got round to looking at the app side of things. Oh well.
Upvotes: 1