Back to project page Antares.
The source code is released under:
Apache License
If you think the Android project Antares 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.takac_j30.antares; /*from w w w .j ava 2 s . com*/ import twitter4j.Twitter; import twitter4j.TwitterException; import twitter4j.User; import twitter4j.auth.AccessToken; import android.content.Intent; import android.graphics.Color; import android.os.AsyncTask; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.view.PagerAdapter; import android.support.v4.view.PagerTabStrip; import android.support.v4.view.ViewPager; import android.util.Log; import android.view.KeyEvent; import android.view.Menu; import android.view.View; import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; import com.loopj.android.image.SmartImageView; public class MainActivity extends FragmentActivity { Twitter tw; ViewPager mViewPager; PagerAdapter mAdapter; LinearLayout profile; SmartImageView icon; TextView name, screenName; public static User user; ViewPager viewPager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //??????????????????????? if (!TwitterUtils.hasAccessToken(getApplicationContext())) { Log.e("main","??????????????"); Intent intent = new Intent(MainActivity.this, OAuthActivity.class); startActivity(intent); finish(); } else { setContentView(R.layout.activity_main); viewPager = (ViewPager) findViewById(R.id.view_pager); viewPager.setAdapter(new CustomPagerAdapter(getSupportFragmentManager())); //PagerTabStrip????? PagerTabStrip pagerTabStrip = (PagerTabStrip) findViewById(R.id.title_strip); pagerTabStrip.setDrawFullUnderline(true); pagerTabStrip.setTabIndicatorColor(Color.rgb(167, 9, 10)); pagerTabStrip.setTextColor(Color.WHITE); tw = TwitterUtils.getTwitterInstance(getApplicationContext()); profile =(LinearLayout) findViewById(R.id.Profile); icon = (SmartImageView) findViewById(R.id.icon); name =(TextView) findViewById(R.id.Name); screenName = (TextView) findViewById(R.id.ScreenName); //???????????????????????? AsyncTask<Void, Void, User> getDataAsync = new AsyncTask<Void, Void, User>() { @Override protected User doInBackground(Void... params) { AccessToken at = TwitterUtils.loadAccessToken(getApplicationContext()); User user = null; Long id = null; try { id = at.getUserId(); Log.e("main", id.toString()); user = tw.showUser(id); return user; } catch (IllegalStateException e) { e.printStackTrace(); } catch (TwitterException e) { e.printStackTrace(); } return null; } @Override public void onPostExecute(User us) { user = us; icon.setImageUrl(us.getProfileImageURL()); name.setText(us.getName()); screenName.setText(us.getScreenName()); profile.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(MainActivity.this, Account.class)); } }); } }; getDataAsync.execute(); } } @Override public void onPause(){ super.onPause(); Log.v("test", "onPause"); stopService(new Intent(getApplicationContext(), AutoReply.class)); startService(new Intent(getApplicationContext(), AutoReply.class)); } @Override public boolean dispatchKeyEvent(KeyEvent e) { if (e.getAction() == KeyEvent.KEYCODE_POWER) { Log.e("test", "????????"); // stopService(new Intent(MainActivity.this, AutoReply.class)); // startService(new Intent(MainActivity.this, AutoReply.class)); } return super.dispatchKeyEvent(e); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } }