So I've built a small Google Glass application using the GDK which basically fakes a push notification by opening a Thread in the background and polling a RESTful webservice every few seconds.
Currently when I open the application it loads and runs the service but the onStart() and onCreate() for the activity (where the Thread is) doesn't get called until the user interacts with the app by opening the menu.
I've never done Android development before so I don't know why my activity might not be loading as soon as the user starts the app.
Here's an overview of some of the code.
public class MainActivity extends Activity {
@Override
protected void onStart()
{
super.onStart();
startThread();
}
Then the actual thread (I know it's terrible it's a prototype :-P)
public void startThread()
{
thread = new Thread()
{
@Override
public void run() {
try {
while(true) {
sleep(5000);
boolean tmp = poll();
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
};
thread.start();
}
And the Android Manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.testpack"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="15" />
<application
android:allowBackup="true"
android:icon="@drawable/logo_box"
android:label="Test">
<uses-library
android:name="com.google.android.glass"
android:required="true" />
<activity
android:name="com.testpack.MainActivity"
android:theme="@style/MenuTheme"
android:enabled="true"/>
<service
android:name="com.testpack.MainService"
android:label="@string/app_name"
android:icon="@drawable/logo_box"
android:enabled="true">
<intent-filter>
<action android:name="com.google.android.glass.action.VOICE_TRIGGER" />
</intent-filter>
<meta-data
android:name="com.google.android.glass.VoiceTrigger"
android:resource="@xml/hello_show" />
</service>
</application>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>