blob: 1b1c3481224f0104b54ceacba47e6d462a650d2c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
package course.labs.permissionslab;
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.Browser;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
public class BookmarksActivity extends Activity {
private static final String TAG = "Lab-Permissions";
static final String[] projection = {
Browser.BookmarkColumns.TITLE,
Browser.BookmarkColumns.URL
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.bookmarks_activity);
Button getBookmarksButton = (Button) findViewById(R.id.get_bookmarks_button);
getBookmarksButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
loadBookmarks();
}
});
Button goToDangerousActivityButton = (Button) findViewById(R.id.go_to_dangerous_activity_button);
goToDangerousActivityButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
startGoToDangerousActivity();
}
});
}
private void loadBookmarks() {
Log.i(TAG, "Entered loadBookmarks()");
String text = "";
Cursor query = getContentResolver().query(Browser.BOOKMARKS_URI, projection, null, null, null);
query.moveToFirst();
while (query.moveToNext()) {
text += query.getString(query
.getColumnIndex(Browser.BookmarkColumns.TITLE));
text += "\n";
text += query.getString(query
.getColumnIndex(Browser.BookmarkColumns.URL));
text += "\n\n";
}
TextView box = (TextView) findViewById(R.id.text);
box.setText(text);
Log.i(TAG, "Bookmarks loaded");
}
private void startGoToDangerousActivity() {
Log.i(TAG, "Entered startGoToDangerousActivity()");
Intent intent = new Intent(BookmarksActivity.this, GoToDangerousActivity.class);
startActivity(intent);
}
}
|