PVODetail.java (3764B)
1 package de.jandankert.hansemerkur; 2 3 import java.io.IOException; 4 5 import de.jandankert.hansemerkur.adapter.PVOCursorAdapter; 6 import de.jandankert.hansemerkur.db.DataBaseHelper; 7 import android.app.Activity; 8 import android.app.AlertDialog; 9 import android.content.ActivityNotFoundException; 10 import android.content.Intent; 11 import android.database.Cursor; 12 import android.database.sqlite.SQLiteDatabase; 13 import android.net.Uri; 14 import android.os.Bundle; 15 import android.view.Menu; 16 import android.view.MenuInflater; 17 import android.view.MenuItem; 18 import android.view.View; 19 import android.widget.AdapterView; 20 import android.widget.CursorAdapter; 21 import android.widget.ListView; 22 import android.widget.TextView; 23 import android.widget.Toast; 24 import android.widget.AdapterView.OnItemClickListener; 25 import android.widget.AdapterView.OnItemLongClickListener; 26 27 public class PVODetail extends Activity 28 { 29 private long plz; 30 private String ort; 31 private String strasse; 32 33 /** Called when the activity is first created. */ 34 @Override 35 public void onCreate(Bundle savedInstanceState) 36 { 37 super.onCreate(savedInstanceState); 38 setContentView(R.layout.pvo_detail); 39 40 DataBaseHelper db = new DataBaseHelper(this); 41 try 42 { 43 db.createDataBase(); 44 } catch (IOException e) 45 { 46 throw new RuntimeException(e); 47 } 48 db.openDataBase(); 49 SQLiteDatabase database = db.getReadableDatabase(); 50 51 plz = this.getIntent().getExtras().getLong("id"); 52 final String sql = "SELECT * from vms where plz='" + plz + "'"; 53 54 final Cursor cursor = database.rawQuery(sql, new String[] {}); 55 56 startManagingCursor(cursor); 57 58 cursor.moveToFirst(); 59 TextView v = (TextView) findViewById(R.id.pvo_ort); 60 v.setText(cursor.getString(cursor.getColumnIndex("Ort"))); 61 TextView vs = (TextView) findViewById(R.id.pvo_str); 62 vs.setText(cursor.getString(cursor.getColumnIndex("Strasse"))); 63 64 this.strasse = cursor.getString(cursor.getColumnIndex("Strasse")); 65 this.ort = cursor.getString(cursor.getColumnIndex("Ort")); 66 67 cursor.close(); 68 } 69 70 public boolean onCreateOptionsMenu(Menu menu) 71 { 72 super.onCreateOptionsMenu(menu); 73 MenuInflater mi = new MenuInflater(getApplication()); 74 mi.inflate(R.menu.detail, menu); 75 76 return true; 77 } 78 79 public boolean onOptionsItemSelected(MenuItem item) 80 { 81 switch (item.getItemId()) 82 { 83 case R.id.itemCall: 84 try 85 { 86 Intent callIntent = new Intent(Intent.ACTION_DIAL); 87 callIntent.setData(Uri.parse("tel:+494041190")); 88 startActivity(callIntent); 89 90 } catch (ActivityNotFoundException e) 91 { 92 Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show(); 93 } 94 break; 95 96 case R.id.itemNav: 97 try 98 { 99 Intent i = new Intent(Intent.ACTION_VIEW, Uri 100 .parse("google.navigation:q=Germany," 101 + strasse.replace(' ', '+') + "," 102 + ort.replace(' ', '+'))); 103 startActivity(i); 104 } catch (ActivityNotFoundException e) 105 { 106 Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show(); 107 } 108 break; 109 110 case R.id.itemMap: 111 112 try 113 { 114 String uri = "geo:0,0?q=Germany,Siegfried-Wedells-Platz+1,Hamburg"; 115 startActivity(new Intent(android.content.Intent.ACTION_VIEW, 116 Uri.parse(uri))); 117 } catch (ActivityNotFoundException e) 118 { 119 Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show(); 120 } 121 break; 122 123 case R.id.item01: 124 super.finish(); 125 break; 126 default: 127 128 } 129 return true; 130 131 // Intent i = new Intent(Intent.ACTION_VIEW, Uri 132 // .parse("google.navigation:q=New+York")); 133 // startActivity(i); 134 135 // Intent callIntent = new Intent(Intent.ACTION_CALL); 136 // callIntent.setData(Uri.parse("tel:123456789")); 137 // startActivity(callIntent); 138 139 // String uri = "geo:"+ latitude + "," + longitude; 140 // startActivity(new Intent(android.content.Intent.ACTION_VIEW, 141 // Uri.parse(uri))); 142 143 } 144 145 }