PageRenderTime 37ms CodeModel.GetById 23ms app.highlight 9ms RepoModel.GetById 2ms app.codeStats 0ms

/BitcoinSpinner/src/com/miracleas/bitcoin_spinner/Main.java

http://bitcoinspinner.googlecode.com/
Java | 37 lines | 32 code | 5 blank | 0 comment | 7 complexity | 4356bc3a2173a29d663a5aeed0213854 MD5 | raw file
 1package com.miracleas.bitcoin_spinner;
 2
 3import android.app.Activity;
 4import android.content.Intent;
 5import android.net.Uri;
 6import android.os.Bundle;
 7
 8import com.bccapi.bitlib.model.NetworkParameters;
 9
10public class Main extends Activity {
11  @Override
12  protected void onCreate(Bundle savedInstanceState) {
13    super.onCreate(savedInstanceState);
14
15    Intent intent = getIntent();
16    final String action = intent.getAction();
17    final Uri intentUri = intent.getData();
18    final String scheme = intentUri != null ? intentUri.getScheme() : null;
19    if (Intent.ACTION_VIEW.equals(action) && intentUri != null && "bitcoin".equals(scheme)) {
20      BitcoinUri b = BitcoinUri.parse(intentUri.toString());
21      if (b == null) {
22        finish();
23      }
24      Intent i = new Intent(this, SendBitcoinsActivity.class);
25      i.putExtra(Consts.BTC_ADDRESS_KEY, b.getAddress());
26      i.putExtra(Consts.BTC_AMOUNT_KEY, b.getAmount());
27      startActivity(i);
28      finish();
29      return;
30    }
31
32    Intent i = new Intent(this, StartUpActivity.class);
33    i.putExtra(Consts.EXTRA_NETWORK, NetworkParameters.productionNetwork);
34    startActivity(i);
35    finish();
36  }
37}