Hello, I use my Main Activity to paint Text. Now Ive a Service in
Background that listens to a bluetooth device. If a button on the
device is pressed I insert values in the local database and want to
repaint the correct value in my Main Activity. Everything works fine -
just the repaint does not work, because i cant call the invalidate()
method from my Service.
I tried with a BroadCastReceiver but i think i misunderstood
something.
----------
This is my Method in my Service "ControllerService"
private void insertToDB(int iWert, char c) {
if(zt.getJoystickMoved().x == iWert) {
sendOrderedBroadcast(i,null);
Log.i("Broadcast","send!");
//in this block i want to notify the Activity
}
}
----------
Here is my Main Activity
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
registerReceiver(resetReceiver, new
IntentFilter("my.intent.INTENT_NAME"));
}
public BroadcastReceiver resetReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Log.i("Broadcast", "got Broadcast!");
MainActivity.this.cc.invalidate();
//cc.invalidate() repaints my Activity
//cc is a View with the paint Logic inside
this.setResultCode(Activity.RESULT_OK);
}
}
My Broadcast Receiver in my Main Activity does not receive
anything ...
I hope someone could help me with my Problem.
----------
In my AndroidManifest is this code
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/
android"
package="com.zaehlwert.countV1"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission
android:name="android.permission.BLUETOOTH" />
<uses-permission
android:name="android.permission.BLUETOOTH_ADMIN" />
<application android:icon="@drawable/icon"
android:label="@string/app_name"
android:name="com.test.data.ListHelper">
<activity android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" /
>
<action android:name="my.intent.INTENT_NAME"/>
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:label="PreferencesActivity"
android:name="PreferencesActivity"></activity>
<activity android:name="ZtPreferencesActivity"
android:label="ZtPreferencesActivity"></activity>
<activity android:name="customizePreferences"></activity>
<activity android:name="ControllerActivity"></activity>
<service android:name="com.test.services.ControllerService"></
service>
<activity android:name="BatteryActivity"></activity>
</application>
</manifest>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en