Back to project page konashi-android-sdk.
The source code is released under:
Apache License
If you think the Android project konashi-android-sdk listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.uxxu.konashi.sample.multi_activity; //from w w w. j a v a2 s . c o m import com.uxxu.konashi.lib.Konashi; import com.uxxu.konashi.lib.KonashiObserver; import android.os.Bundle; import android.renderscript.Sampler; import android.app.Activity; import android.content.Intent; import android.util.Log; import android.view.Menu; import android.view.View; import android.widget.Button; public class MainActivity extends Activity { private static final String TAG = "konashi"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button findButton = (Button)findViewById(R.id.find); findButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Konashi.getManager().find(MainActivity.this); } }); Konashi.initialize(getApplicationContext()); Konashi.getManager().addObserver(mKonashiObserver); } @Override protected void onDestroy() { Konashi.close(); super.onDestroy(); } @Override protected void onResume() { super.onResume(); if(Konashi.getManager()!=null){ Konashi.getManager().disconnect(); } } private final KonashiObserver mKonashiObserver = new KonashiObserver(MainActivity.this) { @Override public void onReady(){ Log.d(TAG, "onKonashiReady"); Konashi.getManager().pwmMode(Konashi.LED2, Konashi.PWM_ENABLE_LED_MODE); Intent intent = new Intent(MainActivity.this, ControllerActivity.class); startActivity(intent); } }; }