Android : Widget AND app: hangs on opening simple Activity

on Sunday, November 2, 2014


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?


0 comments:

Post a Comment