336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
package com.tistory.tansanc.Test130805; import android.app.Activity; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.os.Handler; import android.view.View; public class MainActivity extends Activity { // Introduce an delay private final int WAIT_TIME = 2500; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); findViewById(R.id.mainSpinner1).setVisibility(View.VISIBLE); new Handler().postDelayed(new Runnable() { @Override public void run() { // Simulating a long running task try { Thread.sleep(1000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } /* Create an Intent that will start the ProfileData-Activity. */ SharedPreferences pref = getSharedPreferences("SaveState", 0); float Latitude = pref.getFloat("Latitude", (float) 0.0); if (Latitude == 0.0) { Intent mainIntent = new Intent(MainActivity.this, RegisterActivity.class); MainActivity.this.startActivity(mainIntent); MainActivity.this.finish(); } else { Intent mainIntent = new Intent(MainActivity.this, FindActivity.class); MainActivity.this.startActivity(mainIntent); MainActivity.this.finish(); } } }, WAIT_TIME); } }
package com.tistory.tansanc.Test130805; import android.app.Activity; import android.content.Context; import android.content.SharedPreferences; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.PixelXorXfermode; import android.os.Bundle; import android.os.Handler; import android.view.Menu; import android.view.View; import android.widget.FrameLayout; import android.widget.TextView; public class FindActivity extends Activity { FrameLayout fl; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_find); SharedPreferences pref = getSharedPreferences("SaveState", 0); float Latitude = pref.getFloat("Latitude", (float) 0.0); float Longitude = pref.getFloat("Longitude", (float) 0.0); float Altitude = pref.getFloat("Altitude", (float) 0.0); String sloc = String.format("위도:%f\n경도:%f\n고도:%f", Latitude, Longitude, Altitude); TextView destinationLocation = (TextView) findViewById(R.id.destinationLocation); destinationLocation.setText(sloc); fl = (FrameLayout) findViewById(R.id.fl); RadarView rv = new RadarView(this); fl.addView(rv); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.find, menu); return true; } boolean clock = false; class RadarView extends View { Handler mHandler = new Handler(){ public void handleMessage(android.os.Message msg) { clock = !clock; invalidate(); sendEmptyMessageDelayed(0, 500); }; }; public RadarView(Context context) { super(context); mHandler.sendEmptyMessageDelayed(0, 500); } @Override protected void onDraw(Canvas canvas) { Paint Pnt = new Paint(); Pnt.setAntiAlias(true); if(clock) { Pnt.setColor(Color.RED); } else { Pnt.setColor(Color.WHITE); } canvas.drawCircle(canvas.getWidth()/2, canvas.getHeight()/2, 80, Pnt); Pnt.setXfermode(new PixelXorXfermode(Color.BLACK)); Pnt.setColor(Color.BLUE); canvas.drawRect(100, 100, 200, 200, Pnt); super.onDraw(canvas); } } }
package com.tistory.tansanc.Test130805; import java.util.Map; import java.util.Set; import android.app.Activity; import android.content.Context; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.location.Criteria; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.widget.TextView; public class RegisterActivity extends Activity { LocationManager mLocMan; String mProvider; TextView locationText; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_register); mLocMan = (LocationManager) getSystemService(Context.LOCATION_SERVICE); mProvider = mLocMan.getBestProvider(new Criteria(), true); locationText = (TextView) findViewById(R.id.location); } public void onResume() { super.onResume(); mLocMan.requestLocationUpdates(mProvider, 3000, 10, mListener); } public void mOnClick(View v) { SharedPreferences pref = getSharedPreferences("SaveState", 0); SharedPreferences.Editor edit = pref.edit(); edit.putFloat("Latitude", Latitude); edit.putFloat("Longitude", Longitude); edit.putFloat("Altitude", Altitude); edit.commit(); } float Latitude; float Longitude; float Altitude; LocationListener mListener = new LocationListener() { public void onLocationChanged(Location location) { String sloc = String.format("위도:%f\n경도:%f\n고도:%f", location.getLatitude(), location.getLongitude(), location.getAltitude()); Latitude = (float) location.getLatitude(); Longitude = (float) location.getLongitude(); Altitude = (float) location.getAltitude(); locationText.setText(sloc); } @Override public void onProviderDisabled(String arg0) { // TODO Auto-generated method stub } @Override public void onProviderEnabled(String arg0) { // TODO Auto-generated method stub } @Override public void onStatusChanged(String arg0, int arg1, Bundle arg2) { // TODO Auto-generated method stub } }; @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.register, menu); return true; } }
'Programming > Android' 카테고리의 다른 글
Android 졸업 작품 도움 요청 카페 (0) | 2013.10.22 |
---|---|
Android onTouch 에서 ACTION_DOWN 만 들어올경우 (0) | 2013.10.11 |
PinchToZoom ImageView 로 구현 (0) | 2013.08.23 |
Android 채팅 소스 05 (1) | 2013.08.21 |
Android 채팅 소스 04 (0) | 2013.08.21 |