我需要从IP摄像头获取mjpeg流,任何人都知道正确的方法吗?我用Google搜索了一下,我找到了这个例子
http://www.anddev.org/mjpeg_on_android_anyone-t1871.html
但是当我试图从主要活动调用的另一个活动中获取流时,我一直被困住了.这里的代码:
主要活动
package com.test;
public class IntentTest extends Activity {
/** Called when the activity is first created. */
ListView myListView = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
myListView = (ListView)findViewById(R.id.listView);
final ArrayList<String> items = new ArrayList<String>();
items.add("00408C944B9A");
final ArrayAdapter<String> aa;
aa = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,
items);
myListView.setAdapter(aa);
myListView.setOnItemClickListener(listClicked);
}
private OnItemClickListener listClicked = new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int position, long id) {
// TODO Auto-generated method stub
Intent i …Run Code Online (Sandbox Code Playgroud) 我以这种方式创建了一个接近警报
private void setProximityAlert(float radius, double lat, double lng, String place)
{
long expiration = -1;
LocationManager locManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Intent intent = new Intent(TREASURE_PROXIMITY_ALERT);
intent.putExtra("lat", lat);
intent.putExtra("lng", lng);
intent.putExtra("place", place);
PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), -1, intent, 0);
locManager.addProximityAlert(lat, lng, radius, expiration, pendingIntent);
}
Run Code Online (Sandbox Code Playgroud)
在我的活动中,我以这种方式注册了接收器
IntentFilter intentFilter = new IntentFilter(TREASURE_PROXIMITY_ALERT);
registerReceiver(new ProximityIntentReceiver(), intentFilter);
setProximityAlert(10, 45.150344, 9.999815, "POINT1");
Run Code Online (Sandbox Code Playgroud)
我的广播接收器被正确调用.所以现在,我想添加另一个接近警报,是否可能?我希望2接近警报调用相同的boadcast接收器.我做的:
IntentFilter intentFilter1 = new IntentFilter(TREASURE_PROXIMITY_ALERT1);
registerReceiver(new ProximityIntentReceiver(), intentFilter1);
setProximityAlert(200f, 45.143848, 10.039741, "POINT2");
Run Code Online (Sandbox Code Playgroud)
但它不起作用,没有任何反应.我现在真的很喜欢它,我想知道它是否正确.我的意图是触发2个警报,一个是GPS获取位置POINT1而另一个是POINT2位置.欢迎任何帮助.
我正在用org.json中的lib解析这个JSON字符串,我无法理解为什么我将下面的输出放到日志中.
ArrayList<String> al = new ArrayList<String>();
JSONObject demo = new JSONObject("{\"00408C88A2E6\":{\"id\":\"00408C88A2E6\",\"name\":\"Lab\"},\"00408C91188B\":{\"id\":\"00408C91188B\",\"name\":\"Lab1\"},\"00408C944B99\":{\"id\":\"00408C944B99\",\"name\":\"Lato1\"},\"00408C944BA0\":{\"id\":\"00408C944BA0\",\"name\":\"Lato\"}}");
Iterator<String> iterator = demo.keys();
while (iterator.hasNext() ){
al.add((String)iterator.next());
Log.i(LOG_TAG, "size al into while " + al.size());
Log.i(LOG_TAG, "MAC " + iterator.next() + " for the user " + userId);
}
Run Code Online (Sandbox Code Playgroud)
记录输出
07-12 08:55:34.056: INFO/parse(285): size al into while 1
07-12 08:55:34.056: INFO/parse(285): MAC 00408C91188B for the user nweb
07-12 08:55:34.066: INFO/parse(285): size al into while 2
07-12 08:55:34.066: INFO/parse(285): MAC 00408C944B99 for the user nweb
07-12 08:55:34.066: INFO/parse(285): size …Run Code Online (Sandbox Code Playgroud)