]>
Commit | Line | Data |
---|---|---|
1 | package com.joshuawise.dumload; | |
2 | ||
3 | import java.io.InputStream; | |
4 | ||
5 | import android.app.Activity; | |
6 | import android.app.Service; | |
7 | import android.content.Intent; | |
8 | import android.net.Uri; | |
9 | import android.os.Bundle; | |
10 | import android.os.IBinder; | |
11 | import android.widget.TextView; | |
12 | import android.widget.Toast; | |
13 | import android.util.Log; | |
14 | ||
15 | public class Dumload extends Activity { | |
16 | /** Called when the activity is first created. */ | |
17 | @Override | |
18 | public void onCreate(Bundle savedInstanceState) { | |
19 | super.onCreate(savedInstanceState); | |
20 | setContentView(R.layout.main); | |
21 | TextView tv = (TextView)findViewById(R.id.suckit); | |
22 | tv.setText("Suck it."); | |
23 | } | |
24 | ||
25 | private void say(String s) { | |
26 | Toast.makeText(getApplicationContext(), s, Toast.LENGTH_SHORT).show(); | |
27 | } | |
28 | ||
29 | public void onStart() { | |
30 | super.onStart(); | |
31 | ||
32 | Intent i = getIntent(); /* i *am* not an intent! */ | |
33 | if (i.getAction().equals(Intent.ACTION_SEND)) | |
34 | { | |
35 | Bundle extras = i.getExtras(); | |
36 | Uri uri = (Uri)extras.getParcelable(Intent.EXTRA_STREAM); | |
37 | ||
38 | Log.e("Dumload", "Got a send -- starting service."); | |
39 | // Never let an ML programmer touch Java. | |
40 | android.content.ComponentName cn = getApplicationContext().startService(new Intent().setClass(getApplicationContext(), Uploader.class).setData(uri)); | |
41 | ||
42 | if (cn == null) | |
43 | say("Fuuuuuuuuuck."); | |
44 | else | |
45 | Log.e("Dumload", "Started service " + cn.toString() + "."); | |
46 | ||
47 | TextView tv = (TextView)findViewById(R.id.suckit); | |
48 | tv.setText("Action was send: "+uri.toString()); | |
49 | } else { | |
50 | TextView tv = (TextView)findViewById(R.id.suckit); | |
51 | tv.setText("Action was something else"); | |
52 | } | |
53 | } | |
54 | } |