1
我試圖實現一個Android應用程序, 在主要活動中它顯示一個谷歌地圖,我試圖在相同的佈局上實現一個視圖視圖。 因此,在主地圖活動中(地圖顯示時),我試圖實現一個線程,該線程將同時在地圖視圖下調用videoview活動(進行記錄)。Hcreate在android地圖內的線程
這可能嗎? 因爲我得到很多錯誤。 請任何人都可以幫助我..? 感謝
公共類MainActivity擴展MapActivity實現Runnable {
private MapView mapView;
private MyLocationOverlay myLocationOverlay;
private Button playerbtn;//button to start player
private Button recorderbtn;//button for recorder
private VideoView mVideoView;
private Uri mVideoUri;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mVideoView = (VideoView) findViewById(R.id.videoview);
playerbtn= (Button)findViewById(R.id.playback);
recorderbtn = (Button)findViewById(R.id.recording);
// main.xml contains a MapView
setContentView(R.layout.main);
// extract MapView from layout
mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
// create an overlay that shows our current location
myLocationOverlay = new FixedMyLocationOverlay(this, mapView);
// add this overlay to the MapView and refresh it
mapView.getOverlays().add(myLocationOverlay);
mapView.postInvalidate();
// call convenience method that zooms map on our location
zoomToMyLocation();
}
//--videoview
public void recordingListner(View view) {
Thread toRun = new Thread()
{
public void run()
{
final Intent intent = new Intent(MainActivity.this, VideoRecorder.class);
handleCameraVideo(intent);
startActivity(intent);
}
};
toRun.start();
}
private void handleCameraVideo(Intent intent) {
mVideoUri = intent.getData();
mVideoView.setVideoURI(mVideoUri);
mVideoView.setVisibility(View.VISIBLE);
}
你會得到什麼錯誤? – Ralgha
謝謝Ralgha的回覆,當我運行應用程序時,默認情況下是地圖appers,但是當我按下按鈕啓動位於MapView下方的VideoView時,它會通過從android運行時提供異常syaing IOException來關閉應用程序。我不明白爲什麼?因爲視頻活動也在不同的線程上運行。請幫助我..?謝謝 – user1760933
請發佈完整的日誌輸出。 – Ralgha