How to hide the navigation bar when entering fullview in webview? - java

I have found this code to enter in full screen when playing a video in webview, but there is a problem in it.
For example if I am in YouTube all works properly at the first time (when I play the video), but when I click to change the settings of the video like the quality or the speed, the navigation bar appears and still there until I exit the video.
}
public class CustomWebClient extends WebChromeClient {
private View mCustomView;
private WebChromeClient.CustomViewCallback mCustomViewCallback;
protected FrameLayout frame;
// Initially mOriginalOrientation is set to Landscape
private int mOriginalOrientation = android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
private int mOriginalSystemUiVisibility;
// Constructor for CustomWebClient
public CustomWebClient() {}
public Bitmap getDefaultVideoPoster() {
if (MainActivity.this == null) {
return null; }
return BitmapFactory.decodeResource(MainActivity.this.getApplicationContext().getResources(), 2130837573); }
public void onShowCustomView(View paramView, WebChromeClient.CustomViewCallback viewCallback) {
if (this.mCustomView != null) {
onHideCustomView();
return; }
this.mCustomView = paramView;
this.mOriginalSystemUiVisibility = MainActivity.this.getWindow().getDecorView().getSystemUiVisibility();
// When CustomView is shown screen orientation changes to mOriginalOrientation (Landscape).
MainActivity.this.setRequestedOrientation(this.mOriginalOrientation);
//
//here is the code I'm using to hide status bar
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
// After that mOriginalOrientation is set to portrait.
this.mOriginalOrientation = android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
this.mCustomViewCallback = viewCallback; ((FrameLayout)MainActivity.this.getWindow().getDecorView()).addView(this.mCustomView, new FrameLayout.LayoutParams(-1, -1)); MainActivity.this.getWindow().getDecorView().setSystemUiVisibility(3846);
//
//here is the code I'm using to hide navigation bar
getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
//
}
public void onHideCustomView() {
((FrameLayout)MainActivity.this.getWindow().getDecorView()).removeView(this.mCustomView);
this.mCustomView = null;
MainActivity.this.getWindow().getDecorView().setSystemUiVisibility(this.mOriginalSystemUiVisibility);
// When CustomView is hidden, screen orientation is set to mOriginalOrientation (portrait).
MainActivity.this.setRequestedOrientation(this.mOriginalOrientation);
//////////////
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_IMMERSIVE | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
//////////////
// After that mOriginalOrientation is set to landscape.
this.mOriginalOrientation = android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; this.mCustomViewCallback.onCustomViewHidden();
this.mCustomViewCallback = null;
}
}
{
Here is some pictures of the problem:

Related

Android - Display a screen recording on a SurfaceView

I am developing an application that can record the contents of an Android device's screen and display it on a SurfaceView. As of now, the SurfaceView is a box in the middle of the screen and is currently showing the contents of the entire screen, along with itself, creating a repeating image. Is there a way to repeatedly hide the SurfaceView, create a virtual display, then show the SurfaceView with the contents of the virtual display?
RecordingSession.java
class RecordingSession
implements MediaScannerConnection.OnScanCompletedListener {
static final int VIRT_DISPLAY_FLAGS=
DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY |
DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC;
private RecordingConfig config;
private final File output;
private final Context ctxt;
private final ToneGenerator beeper;
private MediaRecorder recorder;
private MediaProjection projection;
private VirtualDisplay vdisplay;
private Window window;
RecordingSession(Context ctxt, RecordingConfig config,
MediaProjection projection, Window window) {
this.ctxt=ctxt.getApplicationContext();
this.window = window;
this.config=config;
this.projection=projection;
this.beeper=new ToneGenerator(
AudioManager.STREAM_NOTIFICATION, 100);
output=new File(ctxt.getExternalFilesDir(null), "andcorder.mp4");
output.getParentFile().mkdirs();
}
void start() {
//this.window.close();
vdisplay=projection.createVirtualDisplay("andcorder",
config.width, config.height, config.density,
VIRT_DISPLAY_FLAGS, this.window.getScreenShot().getHolder().getSurface(), null, null);
//this.window.open();
beeper.startTone(ToneGenerator.TONE_PROP_ACK);
}
void stop() {
projection.stop();
vdisplay.release();
}
#Override
public void onScanCompleted(String path, Uri uri) {
beeper.startTone(ToneGenerator.TONE_PROP_NACK);
}
}
Window.java
public class Window {
// declaring required variables
private Context context;
private View mView;
private WindowManager.LayoutParams mParams;
private WindowManager mWindowManager;
private LayoutInflater layoutInflater;
public SurfaceView getScreenShot() {
return screenShot;
}
private SurfaceView screenShot;
private LinearLayout toDisplay;
public Window(Context context){
this.context=context;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// set the layout parameters of the window
mParams = new WindowManager.LayoutParams(
// Shrink the window to wrap the content rather
// than filling the screen
WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT,
// Display it on top of other application windows
WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
// Don't let it grab the input focus
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
// Make the underlying application window visible
// through any transparent parts
PixelFormat.TRANSLUCENT);
}
// getting a LayoutInflater
layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// inflating the view with the custom layout we created
mView = layoutInflater.inflate(R.layout.popup_window, null);
screenShot= mView.findViewById(R.id.screenShot);
// Define the position of the
// window within the screen
mParams.gravity = Gravity.CENTER;
mWindowManager = (WindowManager)context.getSystemService(WINDOW_SERVICE);
}
public void open() {
try {
// check if the view is already
// inflated or present in the window
if(mView.getWindowToken()==null) {
if(mView.getParent()==null) {
mWindowManager.addView(mView, mParams);
}
}
} catch (Exception e) {
Log.d("Error1",e.toString());
}
}
public void hide() {
try {
mView.setVisibility(View.INVISIBLE);
} catch (Exception e) {
Log.d("Error3",e.toString());
}
}
public void show() {
try {
mView.setVisibility(View.VISIBLE);
} catch (Exception e) {
Log.d("Error4",e.toString());
}
}
public void close() {
try {
// remove the view from the window
((WindowManager)context.getSystemService(WINDOW_SERVICE)).removeView(mView);
// invalidate the view
mView.invalidate();
// remove all views
((ViewGroup)mView.getParent()).removeAllViews();
// the above steps are necessary when you are adding and removing
// the view simultaneously, it might give some exceptions
} catch (Exception e) {
Log.d("Error2",e.toString());
}
}
}
popup_window.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:padding="4dp"
android:background="#null">
<SurfaceView
android:id="#+id/screenShot"
android:layout_width="match_parent"
android:layout_height="250dp" />
</RelativeLayout>
I have played around with my code and discovered that doubling the virtualdisplay's height and width did the trick. I am a beginner in android development and therefore do not know the reason as to why this worked. If someone can shed light onto why this tweak did the trick, that would be great.
vdisplay=projection.createVirtualDisplay("andcorder",
config.width*2, config.height*2, config.density,
VIRT_DISPLAY_FLAGS, this.window.getScreenShot().getHolder().getSurface(), null, null);

CollapsingToolbarLayout setting scroll flag ENTER_ALWAYS_COLLAPSED programmatically ignored

I'm setting collapingToolbarLayout scroll flags programmatically & it works fine the firs time...
-First fragment:
show an imageView in collapsingToolbar (flags: SCROLL_FLAG_SCROLL,SCROLL_FLAG_ENTER_ALWAYS, SCROLL_FLAG_ENTER_ALWAYS_COLLAPSED) WORKS FINE. then with a button go to second fragment.
-Second Fragment:
remove the imageView (Height = 0dp) and change collapsingToolbar (flags: SCROLL_FLAG_SCROLL,SCROLL_FLAG_ENTER_ALWAYS) WORKS FINE. then onBackPressed go back to first fragment.
-First fragment:
the flag "SCROLL_FLAG_ENTER_ALWAYS" don't work anymore, the collapsingToolbar always scroll to the bottom if i scroll down enough.
I'm making the changes in onDestinationChanged (NavController).
What i tried:
-Setting the flags (SCROLL_FLAG_SCROLL,SCROLL_FLAG_ENTER_ALWAYS, SCROLL_FLAG_ENTER_ALWAYS_COLLAPSED) in XML and just change the imageView visibility state Visible/Gone, same problem.
Some code:
public void onDestinationChanged(#NonNull NavController controller, #NonNull NavDestination destination, #Nullable Bundle arguments) {
appBarLayout.setExpanded(true);
if (destination.getId() == R.id.firstFragment) {
toolbarChanges();
collapsingToolbarChanges();
} else if (destination.getId() == R.id.secondFragment) {
toolbarChangesReset();
collapsingToolbarChangesReset();
}
}
private void toolbarChanges() {
ViewGroup.LayoutParams toolbarImgParams = imgToolbarBackground.getLayoutParams();
final float scale = getResources().getDisplayMetrics().density;
int height = (int) (120 * scale + 0.5f);
toolbarImgParams.height = height;
imgToolbarBackground.setLayoutParams(toolbarImgParams);
}
private void toolbarChangesReset() {
ViewGroup.LayoutParams toolbarImgParams = imgToolbarBackground.getLayoutParams();
toolbarImgParams.height = 0;
imgToolbarBackground.setLayoutParams(toolbarImgParams);
}
private void collapsingToolbarChanges() {
AppBarLayout.LayoutParams collapsingToolbarPrams = (AppBarLayout.LayoutParams) collapsingToolbar.getLayoutParams();
collapsingToolbarPrams.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL |
AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS |
AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS_COLLAPSED);
collapsingToolbar.setLayoutParams(collapsingToolbarPrams);
}
private void collapsingToolbarChangesReset() {
AppBarLayout.LayoutParams collapsingToolbarPrams = (AppBarLayout.LayoutParams) collapsingToolbar.getLayoutParams();
collapsingToolbarPrams.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL |
AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
collapsingToolbar.setLayoutParams(collapsingToolbarPrams);
}

Android Activity Gets Wrong Values After Orientation Change

I have a strange issue & I'm hoping somebody can shed some light on this:
I'm building a dead basic Android app that needs to build a WebRTC video conference & maintain the socket/conference/video on orientation changes. I created a singleton to maintain the connection & all works fine except... after an orientation change my booleans are read incorrectly by the main activity.
The flow is basically:
Fragment state booleans saved to singleton in onDestroyView()
Fragment state booleans loaded from singleton in onCreateView()
The values are correct within the fragment but when I try to read them from the main activity, they are always "false". Why is this?
Also, when I pass them as parameters, they are correct. Why is this?
(For both questions, see communicatorReady() in main activity)
Main activity:
public class MainActivity extends Activity implements Communicator.OnEventListener{
private Communicator communicator = null;
#Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main); // Point to layout/main.xml
// Add fragment to app
communicator = new Communicator();
if(savedInstanceState == null){
getFragmentManager()
.beginTransaction()
.add(R.id.alContainer, communicator)
.commit();
}
}
// Event listener
public void communicatorReady(boolean communicatorReady, boolean communicatorConnected, boolean userConnected){
// Also tried with a communicator.getCommunicatorReady() func, same incorrect result
Log.i(TAG, "communicator.communicatorReady " + (communicatorReady ? "true" : "false")); // Read from object, always false
Log.i(TAG, "communicatorConnected " + (communicatorConnected ? "true" : "false")); // Passed as parameter, correct value
}
}
Fragment:
public class Communicator extends Fragment{
// Communicator stuff
private WebView webComm = null;
private ServiceInfoEvent servInfo = null;
public boolean communicatorReady = false;
public boolean communicatorConnected = false;
public boolean userConnected = false;
// WebRTC stuff
private LocalMedia localMedia = null;
private Conference conference = null;
public CommunicatorEngine communicatorEngine = null;
// Event messages
OnEventListener eventListener;
public interface OnEventListener{
public void communicatorReady(boolean communicatorReady, boolean communicatorConnected, boolean userConnected);
}
#Override
public void onAttach(Activity activity){
super.onAttach(activity);
// Check event listener interface is implemented
try{
eventListener = (OnEventListener) activity;
}
catch(ClassCastException ex){
throw new ClassCastException(activity.toString() + " must implement OnEventListener");
}
}
// Setup the view & comms on fragment creation
public View onCreateView(LayoutInflater inflater, ViewGroup parentViewGroup, Bundle savedInstanceState){
View rootView = inflater.inflate(R.layout.alview, parentViewGroup, false);
communicatorEngine = CommunicatorEngine.getInstance(getActivity());
webComm = communicatorEngine.getWebComm();
if(!communicatorEngine.isWebCommInitialised()){
// Comm webview not initialised, do the initial setup
RelativeLayout.LayoutParams flp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
webComm.setLayoutParams(flp);
webComm.getSettings().setJavaScriptEnabled(true);
webComm.addJavascriptInterface(new ALCTranslator(getActivity()), "appJSInterface");
webComm.loadUrl("file:///android_asset/communicator.html");
webComm.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null);
webComm.setBackgroundColor(Color.TRANSPARENT);
communicatorEngine.setWebCommInitialised(true);
}
else{
// Webview stuff has already run, restore previously saved items
conference = communicatorEngine.getConference();
String peerID = communicatorEngine.getConferencePeerId();
communicatorReady = communicatorEngine.isCommunicatorReady();
communicatorConnected = communicatorEngine.isCommunicatorConnected();
userConnected = communicatorEngine.isUserConnected();
// Add remote video to our view if there is an active conference
if(conference != null && peerID != null){
try{
RelativeLayout incomingStreamContainer = (RelativeLayout) rootView.findViewById(R.id.contIncomingStream);
View remoteVideoControl = (View) LinkExtensions.getRemoteVideoControl(conference.getLink(peerID));
localMedia = new LocalMedia(this);
localMedia.getLayoutManager().addRemoteVideoControl(peerID, remoteVideoControl);
}
catch (Exception e){
e.printStackTrace();
}
}
// Inform the caller that the communicator is ready
eventListener.communicatorReady(communicatorReady, communicatorConnected, userConnected);
}
// Add the webview to the current view
RelativeLayout contCommunicator = (RelativeLayout) rootView.findViewById(R.id.contCommunicator);
contCommunicator.addView(webComm);
return rootView;
}
public void onDestroyView(){
RelativeLayout container = (RelativeLayout) getView().findViewById(R.id.contCommunicator);
container.removeView(webComm);
// Save connection state info
communicatorEngine.setCommunicatorReady(communicatorReady);
communicatorEngine.setCommunicatorConnected(communicatorConnected);
communicatorEngine.setUserConnected(userConnected);
super.onDestroyView();
}
}
Singleton:
public final class CommunicatorEngine{
private static CommunicatorEngine instance = null;
// Communicator stuff
private WebView webALC = null;
private boolean webALCInitialised = false;
private boolean communicatorReady = false;
private boolean communicatorConnected = false;
private boolean userConnected = false;
private Conference conference = null;
private String conferencePeerId = null;
private CommunicatorEngine(Context context){
// Create communicator webview
webALC = new WebView(context);
webALCInitialised = false;
}
public static synchronized CommunicatorEngine getInstance(Context context){
if(instance == null){
// Use app context to prevent memory leaks
instance = new CommunicatorEngine(context.getApplicationContext());
}
return instance;
}
public WebView getWebALC() {return webALC;}
public boolean isWebALCInitialised() {return webALCInitialised;}
public void setWebALCInitialised(boolean isInitialised) {webALCInitialised = isInitialised;}
public boolean isCommunicatorReady(){return communicatorReady;}
public void setCommunicatorReady(boolean isReady){communicatorReady = isReady;}
public boolean isCommunicatorConnected(){return communicatorConnected;}
public void setCommunicatorConnected(boolean isConnected){communicatorConnected = isConnected;}
public boolean isUserConnected(){return userConnected;}
public void setUserConnected(boolean isConnected){userConnected = isConnected;}
public Conference getConference() {return conference;}
public void setConference(Conference conferenceToSave) {conference = conferenceToSave;}
public String getConferencePeerId() {return conferencePeerId;}
public void setConferencePeerId(String peerIdToSave) {conferencePeerId = peerIdToSave;}
}
Edit
Adding log messages produces this:
Fragment﹕ ********* onDestroyView() *********
Fragment﹕ Saved communicatorReady true
Fragment﹕ Saved communicatorConnected true
Fragment﹕ Saved userConnected false
Fragment﹕ ********* onCreateView() *********
Fragment﹕ Loaded communicatorReady true
Fragment﹕ Loaded communicatorConnected true
Fragment﹕ Loaded userConnected false
Activity﹕ communicatorReady Event
Activity﹕ *******************
Activity﹕ Passed as parameter: communicatorReady true
Activity﹕ Passed as parameter: communicatorConnected true
Activity﹕ Passed as parameter: userConnected false
Activity﹕ ********************************
Activity﹕ communicator.communicatorReady false
Activity﹕ communicator.communicatorConnected false
Activity﹕ communicator.userConnected false
Edit 2
The problem goes away if I set the communicator as static:
private static Communicator communicator;
I guess it's an issue with the wrong object being queried.

Setting image resourse by obtaining tag position for an imageview android

I am making use of recycler view. I have a layout that is highlighted in light red,this layout is included for each item in the recycler view. The light red layout is placed over the background image. I am using setTag method to identify the clicks of the buttons in red layout. That is working properly when i click i get the position. The problem is i want to change the image at specific position.
For example : Consider the heart button. I have set a tag on it like this.
heartButton = findViewById(id);
heartButton.setTag(position);
now i get the position by using the getTag method. But now i want to change the image of the heartButton at the a specific position. Is there something like
heartButton.getTag(position).setImageResouce(drawable);
If not how do i do this then.
use setBackgroundResource(R.drawable.XXX)
http://developer.android.com/reference/android/view/View.html#setBackgroundResource(int)
Proper way to do this is,
You have to keep the state of the heart button stored in the model(POJO) which is passed to custom adapter.
e.g.
class ModelListItem{
public static final int HEART=1,BROKEN_HEART=2;
int heartButtonState;
}
Now in onClick() of heart button, get that object from adapter using position,cosidering you have already figured it out on how to preserve position from heart button
ModelListItem item = (ModelListItem)adapter.getItem(position)
Change the state of heart button;
item.setHeartButtonState(ModelListItem.BROKEN_HEART);
adapter.notifyDatasetChanged();
You already know below explaination but just in case
To work this properly,in your getView methode of adapter you need to put the check on heartButtonState(); and use appropriate image resource.
getView(BOILERPLATE){
BOILERPLATE
switch(item.getheartButtonState()){
case ModelItemList.HEART:
heartbutton.setImageResource(heart_image);
break;
case ModelItemList.BROKEN_HEART:
heartbutton.setImageResource(broken_heart_image);
break;
}
I made a custom click listener and updated the like in the setter getter.But this works only when the view has been moved out of the view (i think it is the scrapeview)
The Setter Getter Class
public class DemoData {
int background;
boolean liked;
public DemoData(int background) {
this.background = background;
}
public int getBackground() {
return background;
}
// public void setBackground(int background) {
// this.background = background;
// }
public boolean isLiked() {
return liked;
}
public void setLiked(boolean liked) {
this.liked = liked;
}
}
The onBindViewHolder function of the recycler view
#Override
public void onBindViewHolder(ViewHolder holder, int position) {
background = (ImageView) holder.view.findViewById(R.id.image);
layout = (LinearLayout) holder.view.findViewById(R.id.layout);
delete = (ImageView) layout.findViewById(R.id.delete);
lock = (ImageView) layout.findViewById(R.id.lock);
delete.setTag("delete_"+position);
lock.setTag("lock_"+position);
if(Constants.demoDatas.get(position).isLiked()){
delete.setImageResource(R.drawable.ic_launcher);
}
else{
delete.setImageResource(android.R.drawable.ic_delete);
}
delete.setOnClickListener(new CustomClickListener(position));
lock.setOnClickListener(new CustomClickListener(position));
}
The custom click listener is as below
public class CustomClickListener implements View.OnClickListener {
int position;
public CustomClickListener(int position) {
this.position = position;
}
#Override
public void onClick(View v) {
String tag = (String) v.getTag();
String identifier[] = tag.split("_");
// this line saves my state in the Setter Getter Class
Constants.demoDatas.get(position).setLiked(true);
}
}

Android threading order / ontouch webview

I have a GridView fill with images, when I click on one image, it is displayed in full screen in a PagerActivity and for each images in full screen a piece of html is displayed at the bottom in a webview. On touch some webViews launch a video and some do nothing.
My problem is if I touch a "webView video", the video is displayed in the next layout.
Example : I have 3 images in my Grid. I clicked on the first, this image is displayed in full screen with a webview at the bottom and when I clicked on the webview in order to launch the video on top of the image 1 the video is launched on top of the image 2.
Here a part of my code, ImagePagerActivity :
public class ImagePagerActivity extends BaseActivity {
...
private class ImagePagerAdapter extends PagerAdapter implements OnTouchListener,Handler.Callback {
...
public Object instantiateItem(View view, final int position) {
final View imageLayout = inflater.inflate(R.layout.item_pager_image, null);
final ImageView imageView = (ImageView) imageLayout.findViewById(R.id.image);
final ProgressBar spinner = (ProgressBar) imageLayout.findViewById(R.id.loading);
final WebView webView = (WebView) imageLayout.findViewById(R.id.webView1);
final TextView textView=(TextView) imageLayout.findViewById(R.id.edit_message);
topLevelLayout = (RelativeLayout) imageLayout.findViewById(R.id.top_layout);
videoView = (VideoView) imageLayout.findViewById(R.id.videoView);
topLevelLayout.setBackgroundColor(0x00000000);
((ViewPager) view).addView(imageLayout, 0);
imageLoader.displayImage(images[position], imageView, options, new SimpleImageLoadingListener() {
#Override
public void onLoadingStarted() {
...
}
#Override
public void onLoadingFailed(FailReason failReason) {
...
}
#Override
public void onLoadingComplete(Bitmap loadedImage) {
// HERE ADD THE WEBVIEW ON THE BOTTOM OF THE IMAGE
}
});
return imageLayout;
}
public boolean onTouch(View v, MotionEvent event) {
if(isWebViewLaunchViedo()){
PlayVideo(positionVideo);
}
}
}
I use this project for the GridActivity and PagerActivity Universal image loader
I understand the instantiateItem(..) method is called twice, so that's why when I try to play a video the videoView is already affect to the new one. But I don't know How can I fix this issue?
I finally create a new transparent activity and play the video in the new activity.
Manifest :
<activity
android:name="com.ad.AdVideoActivity"
android:theme="#style/Theme.Transparent" <------
android:label="#string/title_activity_ad_video" >
</activity>
New Ontouch :
public boolean onTouch(View v, MotionEvent event) {
if (ADS_VIDEO.contains(v.getId()) && event.getAction() == MotionEvent.ACTION_DOWN) {
intentVideo = new Intent(getBaseContext(),AdVideoActivity.class);
startActivity(intentVideo);
}
return false;
}

Categories