我在新闻Feed中工作,例如包含列表视图的活动。列表视图包含多个视频,当我单击视频视图时,我打开另一个活动并以全屏模式播放视频。当我按下后,活动无法移动到包含listview的上一个活动。
当我按下按钮时,相同的活动加载它没有去 以前的活动
即使我尝试
finish()
moveTaskToBack(true);
但没用......
我使用了以下代码
ListviewActivity
Intent intent = new Intent(MainActivity.this, VideoActivity.class);
intent.putExtra("VideoURL", MY_VIDEO_URL);
startActivity(intent);
VideoActivity
public class VideoActivity extends Activity {
VideoView videoSurface;
ProgressDialog pDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.video_activity);
ToastMsg.displayShortToastMsg("CREATE");
String videoUrl = getIntent().getStringExtra("VideoURL");
pDialog = new ProgressDialog(VideoActivity.this);
pDialog.setMessage("Loading Please Wait...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(false);
pDialog.show();
videoSurface = (VideoView) findViewById(R.id.videoSurface);
try {
// Start the MediaController
MediaController mediacontroller = new MediaController(
VideoActivity.this);
mediacontroller.setAnchorView(videoSurface);
// Get the URL from String VideoURL
Uri video = Uri.parse(videoUrl);
videoSurface.setMediaController(mediacontroller);
videoSurface.setVideoURI(video);
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
videoSurface.requestFocus();
videoSurface.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
// Close the progress bar and play the video
public void onPrepared(MediaPlayer mp) {
pDialog.dismiss();
videoSurface.start();
}
});
}
@Override
public void onBackPressed() {
super.onBackPressed();
}
}
我的清单文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:uses-implied-permission="http://schemas.android.com/apk/res-
auto"
package="com.stage.lookara"
android:installLocation="auto">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission
android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<application
android:name=".app.AppController"
android:allowBackup="true"
android:configChanges="orientation|keyboardHidden|screenSize"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.Social">
<activity
android:name=".DashBoard"
android:label="@string/app_name"
android:exported="true"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"
/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT"
/>
<data android:host="www.youtube.com"
android:mimeType="text/*" />
</intent-filter>
</activity>
<activity
android:name=".SettingsPage"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden" />
<activity
android:name=".Search"
android:screenOrientation="portrait" />
<activity
android:name=".LookaraNotification"
android:screenOrientation="portrait" />
<activity
android:name=".Login"
android:noHistory="true"
android:screenOrientation="portrait" />
<activity
android:name=".social.SocialActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan|adjustResize" />
<activity
android:name=".social.Comment"
android:screenOrientation="portrait" />
<activity
android:name=".social.ReplyComment"
android:screenOrientation="portrait" />
<activity
android:name=".social.SinglePost"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.DeviceDefault.Light.DialogWhenLarge.NoActionBar" />
<activity
android:name=".social.Profile"
android:screenOrientation="portrait" />
<activity
android:name=".social.FriendProfileView"
android:screenOrientation="portrait" />
<activity
android:name=".social.Friends"
android:screenOrientation="portrait" />
<activity
android:name=".social.IndividualChat"
android:screenOrientation="portrait" />
<activity
android:name=".social.Photos"
android:screenOrientation="portrait" />
<activity
android:name=".social.AlbumViewer"
android:screenOrientation="portrait" />
<activity
android:name=".social.VideoActivity"
android:configChanges="orientation|keyboardHidden|screenSize"/>
<activity
android:name=".social.Event"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden" />
<activity
android:name=".social.JournalActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden" />
<activity
android:name=".social.SocialEditEvents"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden" />
<activity
android:name=".social.SocialFollowers"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden" />
<activity
android:name=".social.SingleEvent"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden" />
<activity
android:name=".social.Message"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan" />
<activity
android:name=".social.GalleryView"
android:screenOrientation="portrait" />
<activity
android:name=".social.Channel"
android:configChanges="orientation|keyboardHidden|screenSize"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden" />
<activity
android:name=".social.MyChannel"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden" />
<activity
android:name=".social.ChannelCreateForm"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden" />
<activity
android:name=".social.ChannelMembers"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden" />
<activity
android:name=".social.ReportDetails"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden" />
<activity
android:name=".social.InvitesList"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden" />
<activity
android:name=".social.OtherUserChannelList"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden" />
<activity
android:name=".social.ChannelProfilePage"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden" />
<activity
android:name=".social.Ask"
android:screenOrientation="portrait" />
<activity
android:name=".social.AskPost"
android:screenOrientation="portrait" />
<activity
android:name=".social.Journal"
android:screenOrientation="portrait" />
<activity
android:name=".PreviewActivity"
android:screenOrientation="portrait" />
<activity
android:name=".social.ChatMessages"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize|adjustPan" />f
<activity
android:name=".social.CreateSocial"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize|adjustPan" />
<activity
android:name=".social.OtherUserFriends"
android:screenOrientation="portrait" />
<activity
android:name=".professinal.ProfessionalSearch"
android:screenOrientation="portrait" />
<activity
android:name=".professinal.ProfessionalActivity"
android:screenOrientation="portrait" />
<activity
android:name=".professinal.CreateProfessional"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden" />
<activity
android:name=".professinal.ProfessionalFollowers"
android:screenOrientation="portrait" />
<activity
android:name=".professinal.ProfessionalJournals"
android:screenOrientation="portrait" />
<activity
android:name=".professinal.ProfessionalConnections"
android:screenOrientation="portrait" />
<activity
android:name=".professinal.FindProfessional"
android:screenOrientation="portrait" />
<activity
android:name=".professinal.ProfessionalMessage"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan" />
<activity
android:name=".professinal.ProfessionalProfile"
android:screenOrientation="portrait" />
<activity
android:name=".common.Reviews"
android:screenOrientation="portrait" />
<activity
android:name=".bussiness.BusinessActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan" />
<activity
android:name=".bussiness.BusinessSearch"
android:screenOrientation="portrait" />
<activity
android:name=".bussiness.Partners"
android:screenOrientation="portrait" />
<activity
android:name=".bussiness.BusinessSettings"
android:screenOrientation="portrait" />
<activity
android:name=".bussiness.CreateBusiness"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden" />
<activity
android:name=".bussiness.BusinessFollowers"
android:screenOrientation="portrait" />
<activity
android:name=".bussiness.BusinessJournals"
android:screenOrientation="portrait" />
<activity
android:name=".bussiness.BusinessList"
android:screenOrientation="portrait" />
<activity
android:name=".bussiness.BusinessMessage"
android:screenOrientation="portrait" />
<activity
android:name=".bussiness.BusinessProfile"
android:screenOrientation="portrait" />
<activity
android:name=".bussiness.BusinessOverView"
android:screenOrientation="portrait" />
<activity
android:name=".bussiness.BusinessSpecialOffer"
android:screenOrientation="portrait" />
<activity
android:name=".bussiness.ContactDetails"
android:screenOrientation="portrait" />
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden
|screenLayout|screenSize|orientation"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
/>
<activity
android:name="com.darsh.multipleimageselect.
activities.AlbumSelectActivity"
android:theme="@style/MultipleImageSelectTheme">
<intent-filter>
<category android:name="android.intent.category.DEFAULT"
/>
</intent-filter>
</activity>
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/FB_APP_ID" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<receiver
android:name=".NetworkChangeReceiver"
android:label="NetworkChangeReceiver">
<intent-filter>
<action
android:name="android.net.conn.CONNECTIVITY_CHANGE" />
<action
android:name="android.net.wifi.WIFI_STATE_CHANGED" />
</intent-filter>
</receiver>
<service android:name=".common.LookaraService" />
<service android:name=".common.LookaraUploadService" />
</application>
</manifest>
答案 0 :(得分:0)
尝试将以下内容添加到清单中。
$result = $this->db->select('CASE WHEN b.name IS NOT NULL THEN CONCAT(a.name, ,\' -> \' b.name) ELSE a.name END AS option')
->from('yourtable a')
->join('yourtable b', 'a.parent = b.id', 'left')
->get()->result();
答案 1 :(得分:0)
试试这个: -
videoSurface.setMediaController(new MediaController(this){
public boolean dispatchKeyEvent(KeyEvent event){
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP)
finish();
return super.dispatchKeyEvent(event);
}
});
答案 2 :(得分:0)
请检查您是否添加了元数据
<activity
android:name=".VideoActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="YOUR_PAKAGE_NAME.VideoListActivity" />
</activity>
用于Manifest文件中的VideoActivity。
答案 3 :(得分:0)
VideoView
可能会消耗ACTION_DOWN
事件,因此KEYCODE_BACK永远不会触发dispatchKeyEvent().
来自Context
在您的活动中使用此代码:
videoSurface.setMediaController(new MediaController(this){
public boolean dispatchKeyEvent(KeyEvent event)
{
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK)
((Activity) getContext()).finish(); //finish current activity
return super.dispatchKeyEvent(event);
}
});