Posts

Showing posts with the label android-activity

Access button from Layout within GlSurfaceView

Image
Clash Royale CLAN TAG #URR8PPP Access button from Layout within GlSurfaceView I am working on Android and have being working on OpenGL ES. I have a xml layout as follows (I have took some things out to show only therelative content: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:ads="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:id="@+id/myText"/> <MyGLSurfaceView android:id="@+id/mySurface"/> Then in my GlSurfaceView I am trying to access the button that is in the same layout. However this is were I am having a problem. I have tried the following: View v = (View) getParent(); myTextViewString = (TextView) v.findViewById(R.id.myText); this myTextViewString = (TextView) findViewById(R.id.myText); and this myTextViewString...

Communicate with Activity from Service (LocalService) - Android Best Practices

Image
Clash Royale CLAN TAG #URR8PPP Communicate with Activity from Service (LocalService) - Android Best Practices Common scenario - Activity with a background Service to poll server. The Service will run periodically via AlarmManager and also perform tasks for the Activity (user hits a button, go fetch something from server). I'd like to know the best practices here. I think the best design would be the Android LocalService example: http://developer.android.com/reference/android/app/Service.html#LocalServiceSample However in the example the Activity has a reference to the activity mBoundService but there is no reverse connection ( the Service has no way to call the Activity ). mBoundService What is the best way for the Service to call the Activity? Do I use Intents, BroadcastReceivers, Messages? How? 3 Answers 3 I think the best design would be the Android LocalService example: http://developer...