Back to project page Android_Oauth_Demo.
The source code is released under:
MIT License
If you think the Android project Android_Oauth_Demo 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.example.sdnusdk; // w ww. j ava2 s. c o m import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; import cn.edu.sdnu.i.util.oauth.AppSDNU; import cn.edu.sdnu.i.util.oauth.Constants; import cn.edu.sdnu.i.util.oauth.Oauth; import com.example.sdnusdk.R; public class MainActivity extends Activity{ TextView textDisp ; private String resultDisp; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.mainactivity); textDisp = (TextView)findViewById(R.id.textView1); ((Button)findViewById(R.id.getPeople)).setOnClickListener(new OnClickListener(){ @Override public void onClick(View arg0) { // TODO Auto-generated method stub Oauth.startThread(mHandler, AppSDNU.get(Constants.BASE_URL) //????????????. + AppSDNU.get(Constants.REST_URL) +"card/get",Oauth.METHOD,MainActivity.this); } }); ((Button)findViewById(R.id.logout)).setOnClickListener(new OnClickListener(){ @Override public void onClick(View arg0) { // TODO Auto-generated method stub //?????.?????? ?? token????. Oauth.setToken("", ""); //?????? Utils.saveTokenValue(MainActivity.this, "", Utils.TOKENVALUE, Context.MODE_PRIVATE); Toast.makeText(getApplication(), "?????", Toast.LENGTH_SHORT).show(); } }); } private Handler mHandler =new Handler(new Handler.Callback(){ String result = null; @Override public boolean handleMessage(Message msg){ result = (String)msg.obj; switch (msg.what) { case Oauth.ERROR: Toast.makeText(MainActivity.this, "?????,?????!", Toast.LENGTH_SHORT).show(); break; case Oauth.METHOD: decodeMethod(result); default: break; } return false; } }); private void decodeMethod(String result2) { // TODO Auto-generated method stub resultDisp+= (result2+"\n"); textDisp.setText(resultDisp); } @Override protected void onPause() { // TODO Auto-generated method stub super.onPause(); } @Override protected void onResume() { // TODO Auto-generated method stub super.onResume(); } }