-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathECLIPSE1.txt
157 lines (86 loc) · 3.3 KB
/
ECLIPSE1.txt
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
public class MainActivity extends Activity {
VideoView videoView;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
this.setContentView(R.layout.activity_main);
videoView = (VideoView)this.findViewById(R.id.videoView1);
MediaController mc = new MediaController(this);
videoView.setMediaController(mc);
videoView.setVideoURI(Uri.parse("rtsp://192.168.3.142:554/live/myStream"));
videoView.start();
videoView.requestFocus();
}
private long lastPressedTime;
private static final int PERIOD = 2000;
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
switch (event.getAction()) {
case KeyEvent.ACTION_DOWN:
if (event.getDownTime() - lastPressedTime < PERIOD) {
finish();
} else {
Toast.makeText(getApplicationContext(), "ÇÖÛØ Úáì ÒÑ ÇáÚæÏÉ ãÑÉ ËÇäíÉ ááÎÑæÌ ãä ÇáÊØÈíÞ",
Toast.LENGTH_SHORT).show();
lastPressedTime = event.getEventTime();
}
return true;
}
}
return false;
}
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".MainActivity" >
<VideoView
android:id="@+id/videoView1"
android:layout_width="fill_parent"
android:layout_alignParentRight="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_height="fill_parent" />
</RelativeLayout>
private final int ID_MENU_EXIT = 1;
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
//check selected menu item
if(item.getItemId() == ID_MENU_EXIT)
{
//close the Activity
this.finish();
return true;
}
return false;
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
//the menu option text is defined in resources
//get a SubMenu reference
SubMenu sm = menu.addSubMenu("About...");
//add menu items to the submenu
sm.add("ÊØÈíÞ ÞäÇÉ ÇáÊáÝÒíæä ÇáÊÑÈæí");
sm.add("ÇáãÕãã ÇÍãÏ ÇáÍáí");
sm.add("Email:[email protected]");
//it is better to use final variables for IDs than constant values
//menu.add(Menu.NONE,1,Menu.NONE,"Exit");
//get the MenuItem reference
MenuItem item =
menu.add(Menu.NONE,ID_MENU_EXIT,Menu.NONE,R.string.exitOption);
//set the shortcut
item.setShortcut('5', 'x');
//the menu option text is defined as constant String
return true;
}
<string name="exitOption">Exit</string>
<string name="aboutOption">About</string>