PageRenderTime 52ms CodeModel.GetById 30ms app.highlight 5ms RepoModel.GetById 15ms app.codeStats 0ms

/RMaps.Ext/src/com/robert/maps/ext/DonationActivity.java

http://robertprojects.googlecode.com/
Java | 49 lines | 36 code | 13 blank | 0 comment | 0 complexity | 6f156cc1a9d3261c01f62aa56c94a0f3 MD5 | raw file
 1package com.robert.maps.ext;
 2
 3import android.app.Activity;
 4import android.content.ActivityNotFoundException;
 5import android.content.ComponentName;
 6import android.content.Intent;
 7import android.net.Uri;
 8import android.os.Bundle;
 9import android.view.View;
10import android.widget.Toast;
11
12public class DonationActivity extends Activity {
13
14	@Override
15	protected void onCreate(Bundle savedInstanceState) {
16		super.onCreate(savedInstanceState);
17
18		setContentView(R.layout.donationactivity);
19
20		findViewById(R.id.buttonStart).setOnClickListener(new View.OnClickListener() {
21
22			public void onClick(View v) {
23				try {
24					final Intent intent = new Intent(Intent.ACTION_MAIN, null);
25
26					intent.addCategory(Intent.CATEGORY_LAUNCHER);
27
28					final ComponentName cn = new ComponentName("com.robert.maps", "com.robert.maps.applib.MainActivity");
29
30					intent.setComponent(cn);
31
32					intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
33
34					startActivity(intent);
35
36				} catch (ActivityNotFoundException e) {
37					Toast.makeText(DonationActivity.this, R.string.message_noapp, Toast.LENGTH_LONG).show();
38					try {
39						startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse("market://details?id=com.robert.maps")));
40					} catch (Exception e1) {
41						e1.printStackTrace();
42					}
43				}
44				DonationActivity.this.finish();
45			}
46		});
47	}
48
49}