Coder Social home page Coder Social logo

cwac-presentation's Introduction

CWAC-Presentation: Second Screens Supported Succinctly

UPDATE 2021-05-08: This project is discontinued. This repository will be removed from public access on or after 1 December 2021.

This project offers a series of classes that wrap around Presentation and DisplayManager:

  • PresentationHelper consolidates basic DisplayManager handling, with a listener to inform you when to show or remove your Presentation

  • PresentationFragment extends DialogFragment and adds a bit of extra logic to allow it to handle a Presentation rather than a simple Dialog

  • WebPresentationFragment simply extends PresentationFragment and displays a WebView in the Presentation

  • MirroringFragment, MirroringWebViewFragment, and MirrorPresentationFragment leverage the mirroring logic from the CWAC-Layouts project to help you display a Presentation based upon mirrored content from the main screen

  • PresentationService, for showing content on an external display from the background, even if your primary UI is destroyed or otherwise not in the foreground

Installation

This project is available as an artifact for use with Gradle.

There are two versions of this library, for AndroidX and for the older Android Support Library.

If you cannot use SSL, use http://repo.commonsware.com for the repository URL.

AndroidX

repositories {
    maven {
        url "https://s3.amazonaws.com/repo.commonsware.com"
    }
}

dependencies {
    implementation 'com.commonsware.cwac:presentation.x:0.6.1'
}

Android Support Library

repositories {
    maven {
        url "https://s3.amazonaws.com/repo.commonsware.com"
    }
}

dependencies {
    implementation 'com.commonsware.cwac:presentation:0.5.3'
}

Usage: PresentationHelper

PresentationHelper is designed to be used by an Activity that wishes to display a Presentation when a suitable Display is attached, and stop displaying the Presentation when any prior such Display is detached.

To do this:

  • Create an instance of PresentationHelper, probably in onCreate() of the activity. You will need to supply a Context (probably this) and something that implements the PresentationHelper.Listener interface.

  • Forward the onPause() and onResume() events to the PresentationHelper by calling the same-named methods on the helper.

  • Implement the showPreso() method on your Listener. This receives a Display object, and you are now able to display a Presentation on that Display.

  • Implement the clearPreso() method on your Listener. At this point, you should stop displaying any prior Presentation, if there was one. You are passed a boolean value, true indicating that the activity is going away, false indicating that we merely lost our Display. You can use this value to perhaps optimize dealing with Display changes, without destroying all the data.

You can call disable() and enable() on the PresentationHelper. Calling disable() stops the custom content and reverts the device to normal screen mirroring mode. Calling enable() reverts a previous disable() call.

Usage: PresentationFragment

PresentationFragment is a thin veneer over DialogFragment to allow it to work with Presentation objects (which themselves inherit from Dialog). This allows you to define the content for a Presentation in the form of a fragment. And, like DialogFragment, you can elect to either use it for a Presentation (via a call to show()) or use it as an ordinary Fragment in the rest of your UI (via a FragmentTransaction). This can help you to work both in dual-screen and single-screen scenarios.

Your PresentationFragment subclass should override onCreateView() to define the contents of the Presentation (or what will be shown in the Fragment when used as a regular fragment). The only significant change over any other Fragment is that you should use getContext(), instead of getActivity(), for any resources you create, such as inflating a layout. This ensures that you get the right Context for the situation, such as the Context associated with a secondary screen when used for a Presentation.

However, when creating the PresentationFragment, you also need to call setDisplay(), to provide the Display object for use when the fragment is shown as a Presentation. If you are not using it for a Presentation in the current context, this call is not required. A typical approach for handling setDisplay() is to use a factory method:

public static YourFragment newInstance(Context ctxt, Display display) {
  YourFragment frag=new YourFragment();

  frag.setDisplay(ctxt, display);

  return(frag);
}

Beyond this, PresentationFragment is a fairly ordinary Fragment.

If you wish to display this fragment in a Presentation, call show() on the PresentationFragment, supplying your FragmentManager and a tag to use for the fragment itself. To get rid of the Presentation, call dismiss() on the PresentationFragment.

NOTE: In the AndroidX artifacts (presentation.x), PresentationFragment extends androidx.fragment.app.Fragment. In the legacy artifact (presentation), PresentationFragment extends android.app.Fragment.

Usage: WebPresentationFragment

WebPresentationFragment is simply a mash-up of PresentationFragment and WebViewFragment, to allow a WebView to be displayed in a Presentation. You use it just like WebViewFragment, except for the need to call setDisplay() (per the PresentationFragment instructions above). So, for example, getWebView() returns the WebView hosted by the WebPresentationFragment.

NOTE: In the AndroidX artifacts (presentation.x), WebPresentationFragment inherits from androidx.fragment.app.Fragment. In the legacy artifact (presentation), WebPresentationFragment inherits from android.app.Fragment.

Usage: Mirroring Presentation Classes

There are three classes that take advantage of the mirroring support included in the CWAC-Layouts project.

MirroringFragment works much like a regular Fragment. However, instead of overriding onCreateView(), you override onCreateMirroredContent(). onCreateMirroredContent() takes the same parameters as does onCreateView(), and your job is the same: create the content to be displayed by the fragment. The difference is that your returned View will be wrapped in a MirroringFrameLayout.

MirroringWebViewFragment is a mash-up of MirroringFragment and WebViewFragment, to allow a WebView to be mirrored. Use getWebView() to retrieve the WebView hosted by this fragment.

MirrorPresentationFragment is a PresentationFragment designed to mirror the contents of a MirroringFragment. To use this, create an instance using the newInstance() factory method, taking a Context and the desired Display as parameters. Then, call setMirror() on your MirroringFragment, supplying the MirrorPresentationFragment. From there, you can show() and dismiss() the MirrorPresentationFragment as you would any other PresentationFragment. By having the MirroringFragment on the main screen, and having the MirrorPresentationFragment on an external display, whatever the user manipulates on the screen is rendered to the external display, ideal for presentation settings (e.g., conferences).

Note that MirroringFragment suffers the same limitations as does MirroringFrameLayout, in that it will work with fairly ordinary Views, plus WebView, but not SurfaceView or things that use SurfaceView (e.g., VideoView, Maps V2 maps).

NOTE: In the AndroidX artifacts (presentation.x), these fragments inherit from androidx.fragment.app.Fragment. In the legacy artifact (presentation), these fragments inherit from android.app.Fragment.

Usage: PresentationService

PresentationService is an abstract base class for you to extend, where PresentationService handles showing your content on an external display, and you simply manage that content.

In your PresentationService subclass, you will need to implement two methods:

  • getThemeId(), which returns the ID of the style resource that you want to use for content being shown on the external display.

  • buildPresoView(), which returns the View that represents the content to show on the external display. Note that since this is a Service, not an Activity, you cannot use fragments, only views. buildPresoView() is passed a Context and a LayoutInflater for your use to set up the content to be displayed.

You may optionally override the standard lifecycle methods (though please chain to the superclass!) and buildLayoutParams(), which returns a WindowManager.LayoutParams describing how your View should be applied to the external display. The default implementation of buildLayoutParams() is probably adequate for your needs.

You may also optionally override the showPreso() and clearPreso() methods defined by PresentationHelper.Listener, though, once again, please chain to the superclass implementations.

You may also optionally override getWindowType(). This should return the window type int to be used for the "window" we are going to use for the external display. The stock implementation of getWindowType() uses TYPE_TOAST prior to Android 7.1 and TYPE_SYSTEM_ALERT on Android 7.1+. If you are using Cast Remote Display, you may need to override this method and return TYPE_PRIVATE_PRESENTATION (untested).

Then, all you need to do is to arrange to start and stop the service as needed. Once started, the service will automatically call buildPresoView() and show the content, once an external display is detected.

If things that the user does in your UI should affect the behavior of the service and its content, use a message bus implementation, such as LocalBroadcastManager. Your PresentationService can receive bus messages and update the View accordingly. Note that there is no present means to replace the View, so you may wish to have buildPresoView() return a FrameLayout or something else whose contents you can replace in toto if needed.

Note that it is safe to call startService() on the service multiple times, if you do not know whether the service is already running and need to ensure that it is running now.

Note that using this on Android 7.1+, where a TYPE_SYSTEM_ALERT window is used, requires the user to go into Settings and allow your app to draw over other apps.

On Android 8.0+, please use multi-display instead of PresentationService. However, PresentationService will work on Android 8.0+ if needed.

JavaDocs

You can browse the JavaDocs for the latest release.

Dependencies

This project depends on Android 4.2 and higher (API Level 17) to actually do its work.

This project also depends upon the CWAC-Layouts project.

The AndroidX edition of this artifact (presentation.x) depends upon androidx.fragment:fragment.

Version

This is version v0.6.1 of this artifact, meaning it is coming along nicely.

Note that the Android Support library edition of this arifact (presentation) remains at 0.5.3. Outside of critical bug fixes, no further work is planned for this version.

Demo

In the demo/ sub-project you will find a sample project demonstrating the use of the aforementioned classes, with the exception of PresentationService. There is a separate demoService/ sub-project with a sample implementation of PresentationService.

Additional Documentation

The Busy Coder's Guide to Android Development contains a chapter dedicated to the Presentation API. This chapter walks through a few sample apps that use classes from this library. Another chapter in the book examines a somewhat larger app that supports output on TVs, etc. by a variety of means (e.g., direct-to-TV devices like Android TV and Fire TV) including Presentation and this library's classes.

License

The code in this project is licensed under the Apache Software License 2.0, per the terms of the included LICENSE file.

Questions

If you have questions regarding the use of this code, please post a question on Stack Overflow tagged with commonsware-cwac and android after searching to see if there already is an answer. Be sure to indicate what CWAC module you are having issues with, and be sure to include source code and stack traces if you are encountering crashes.

If you have encountered what is clearly a bug, or if you have a feature request, please post an issue. The contribution guidelines provide some suggestions for how to create a bug report that will get the problem fixed the fastest.

You are also welcome to join the CommonsWare Community and post questions and ideas to the CWAC category.

Do not ask for help via social media.

Also, if you plan on hacking on the code with an eye for contributing something back, please open an issue that we can use for discussing implementation details. Just lobbing a pull request over the fence may work, but it may not. Again, the contribution guidelines provide a bit of guidance here.

Release Notes

  • v0.6.1: fixed less-than bug
  • v0.6.0: migrated to AndroidX and started a new artifact (presentation.x)
  • v0.5.3: fixed less-than bug
  • v0.5.2: added support for Android 8.0+
  • v0.5.1: updated to new Gradle, Android Plugin for Gradle, etc.
  • v0.5.0: better PresentationService support for Android 7.1+, demo bug fixes
  • v0.4.6: JavaDocs, sources included in repo; source tree reorg; build files update
  • v0.4.5: got PresentationService working again on Android 5.1
  • v0.4.4: updated for Android Studio 1.0 and new AAR publishing system
  • v0.4.3: removed SYSTEM_ALERT_WINDOW permission requirement
  • v0.4.2: updated Gradle, fixed manifest for merging, added cwac- prefix to JAR
  • v0.4.1: tweak for v0.4.0 of CWAC-Layouts
  • v0.4.0: added PresentationService
  • v0.3.0: migrated to Gradle
  • v0.2.0: handle API level diffs, support enable/disable of PresentationHelper
  • v0.1.0: initial release

Who Made This?

CommonsWare

cwac-presentation's People

Contributors

commonsguy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cwac-presentation's Issues

Use Presentation with Canvas

Hello,

thank you very much for the great insight in the Presentation API.
In my case I have an APP that need to gets it input from a canvas. On the phones display I get the X/Y Coordinates from View/Canvas and I want to display these coordinates as a circle on the second screen. I've tried to combine the Multitouch example from google and your classes into one APP but I'm struggling with the basics.

Could you suggest a way how I could draw on the phone and get these coordinates displayed on the second screen? On the phone there is a camera live-view image displayed. It's part of my microscopy-research ;)

Thank you so much for any help!! :)
BTW your books are fantastic!

Best regards

Implementation like FragmentPagerStateAdapter

I really like your library and changed my implementation into this. But after hours of refactoring and working, I got a very slow application. I was using FragmentStatePagerAdapter which as you know only store 3 Fragments at a time at most. I have more then 100 items and this becomes very slow.

Update Build Instructions

This uses an old Gradle wrapper and an old Android Plugin for Gradle. Update these to something more current.

Issue when saving & restoring state

The project crashes whenever it is restoring the state in the ArrayPagerAdapter class. (Includes the Demos)

I fixed this by having the correct ClassLoaders in the PageEntry class:

PageEntry(Parcel in) {
        this.descriptor = in.readParcelable(getClass().getClassLoader());
        this.state = in.readParcelable(getClass().getClassLoader());
    }

And in save/restore methods:

@Override
public Parcelable saveState() {
    final Bundle state = new Bundle();
    state.putParcelableArrayList(KEY_DESCRIPTORS, entries);
    state.setClassLoader(getClass().getClassLoader());
    return state;
}

@Override
public void restoreState(Parcelable state, ClassLoader loader) {
    final Bundle bundle = (Bundle) state;
    bundle.setClassLoader(loader);
    entries = ((Bundle) state).getParcelableArrayList(KEY_DESCRIPTORS);
}

And finally to wrap this up this is the exception which was thrown. And I can confirm that this is working correctly by doing the above changes.

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.commonsware.cwac.pager.demo/com.commonsware.cwac.pager.demo.MainActivity}: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.commonsware.cwac.pager.v4.ArrayPagerAdapter$PageEntry

PresentationService does not work with Android 7.1

On Android 7.1, content displayed using the PresentationService method works only for a few seconds, then the content fades out and it stops working.

Tested the presentation service demo on:

Android 7.1 device and emulator - both did not work
Android 7.0 emulator - worked correctly

So it appears that there was a change in Android 7.1 that's causing this to not work anymore.

The most puzzling part is that it does work for a few seconds, then fades out and stops working. As far as I can tell, none of the DisplayListener callbacks are being called when this occurs, so there's no way of even knowing that it has stopped working (from the app's point of view).

I'm wondering if the WindowManager.LayoutParams type and/or flags need tweaking to work on Android 7.1, or if this is simply a bug in Android 7.1.

Issue regarding com.commonsware.cwac.pager

Hi,

when i used pager control its working fine i was able to add and remove multiple pages in pageveiw control but when a button click in any page fragnent and add another fragment in the same container where the view pager exits and again want to back the previous fragment its show error list this

for go back i used this
getFragmentManager().popBackStack();

12-09 07:38:04.065: E/AndroidRuntime(3328): FATAL EXCEPTION: main
12-09 07:38:04.065: E/AndroidRuntime(3328): java.lang.IllegalStateException: Recursive entry to executePendingTransactions
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1388)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:431)
12-09 07:38:04.065: E/AndroidRuntime(3328): at com.commonsware.cwac.pager.v4.ArrayPagerAdapter.finishUpdate(ArrayPagerAdapter.java:155)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.support.v4.view.ViewPager.populate(ViewPager.java:804)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:433)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:405)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.support.v4.view.ViewPager.onRestoreInstanceState(ViewPager.java:898)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.view.View.dispatchRestoreInstanceState(View.java:12093)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2582)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2588)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.view.View.restoreHierarchyState(View.java:12071)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.support.v4.app.Fragment.restoreViewState(Fragment.java:407)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:897)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1080)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:622)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1416)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:431)
12-09 07:38:04.065: E/AndroidRuntime(3328): at com.commonsware.cwac.pager.v4.ArrayPagerAdapter.finishUpdate(ArrayPagerAdapter.java:155)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.support.v4.view.ViewPager.populate(ViewPager.java:804)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:433)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:405)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.support.v4.view.ViewPager.onRestoreInstanceState(ViewPager.java:898)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.view.View.dispatchRestoreInstanceState(View.java:12093)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2582)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2588)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.view.View.restoreHierarchyState(View.java:12071)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.support.v4.app.Fragment.restoreViewState(Fragment.java:407)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:897)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1080)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.support.v4.app.BackStackRecord.popFromBackStack(BackStackRecord.java:697)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.support.v4.app.FragmentManagerImpl.popBackStackState(FragmentManager.java:1465)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.support.v4.app.FragmentManagerImpl.popBackStackImmediate(FragmentManager.java:447)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.support.v4.app.FragmentActivity.onBackPressed(FragmentActivity.java:164)
12-09 07:38:04.065: E/AndroidRuntime(3328): at com.gensuite.enterprise.EnterpriseFragmentActivity.onBackPressed(EnterpriseFragmentActivity.java:54)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.app.Activity.onKeyUp(Activity.java:2145)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.view.KeyEvent.dispatch(KeyEvent.java:2633)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.app.Activity.dispatchKeyEvent(Activity.java:2375)
12-09 07:38:04.065: E/AndroidRuntime(3328): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1847)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1359)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1359)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1359)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.widget.TabHost.dispatchKeyEvent(TabHost.java:324)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1359)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1359)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1359)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1359)
12-09 07:38:04.065: E/AndroidRuntime(3328): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:1920)
12-09 07:38:04.065: E/AndroidRuntime(3328): at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1395)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.app.Activity.dispatchKeyEvent(Activity.java:2370)
12-09 07:38:04.065: E/AndroidRuntime(3328): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1847)
12-09 07:38:04.065: E/AndroidRuntime(3328): at android.view.ViewRootImpl.del

PresentationService does not require TYPE_SYSTEM_ALERT / SYSTEM_ALERT_WINDOW

I cloned the demoService project and added a local copy of the PresentationService class (so I could edit it). The only changes I made were:

  • Removed WindowManager.LayoutParams.TYPE_SYSTEM_ALERT from buildLayoutParams() (replaced with just 0)
  • Removed <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/> from AndroidManifest.xml

It seems to work without the layout params type and associated permission. I tested this on physical devices (Note 3 and Note 10.1 2014 Edition, both API 19) using a Chromecast in mirror mode. I also tested this on an API 17 emulator using the secondary display developer option.

I assume you thought this layout params type and permission were necessary, but that appears not to be the case (which is obviously good news). Unless there's some case I'm missing where this is required... Thoughts?

crash on Android 7.1.1

Hello,
I just checked out "master", imported in Android Studio and ran (otherwise untouched) on an Android 7.1.1 device.
it crashes on me with

2020-10-28 10:38:24.687 5315-5315/? W/System: ClassLoader referenced unknown path: /data/app/com.commonsware.cwac.preso.demo.service-1/lib/arm64
2020-10-28 10:38:24.726 5315-5315/? W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter androidx.vectordrawable.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
2020-10-28 10:38:24.753 5315-5315/? V/BoostFramework: mAcquireFunc method = public int com.qualcomm.qti.Performance.perfLockAcquire(int,int[])
2020-10-28 10:38:24.753 5315-5315/? V/BoostFramework: mReleaseFunc method = public int com.qualcomm.qti.Performance.perfLockRelease()
2020-10-28 10:38:24.753 5315-5315/? V/BoostFramework: mAcquireTouchFunc method = public int com.qualcomm.qti.Performance.perfLockAcquireTouch(android.view.MotionEvent,android.util.DisplayMetrics,int,int[])
2020-10-28 10:38:24.753 5315-5315/? V/BoostFramework: mIOPStart method = public int com.qualcomm.qti.Performance.perfIOPrefetchStart(int,java.lang.String)
2020-10-28 10:38:24.753 5315-5315/? V/BoostFramework: mIOPStop method = public int com.qualcomm.qti.Performance.perfIOPrefetchStop()
2020-10-28 10:38:24.756 5315-5315/? V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@d805c71
2020-10-28 10:38:24.756 5315-5315/? V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@c37fa56
2020-10-28 10:38:24.764 5315-5315/? I/art: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
2020-10-28 10:38:24.764 5315-5315/? I/art:     at void androidx.core.view.ViewCompat.setBackground(android.view.View, android.graphics.drawable.Drawable) (ViewCompat.java:2341)
2020-10-28 10:38:24.764 5315-5315/? I/art:     at void androidx.appcompat.widget.ActionBarContainer.<init>(android.content.Context, android.util.AttributeSet) (ActionBarContainer.java:62)
2020-10-28 10:38:24.764 5315-5315/? I/art:     at java.lang.Object java.lang.reflect.Constructor.newInstance0!(java.lang.Object[]) (Constructor.java:-2)
2020-10-28 10:38:24.764 5315-5315/? I/art:     at java.lang.Object java.lang.reflect.Constructor.newInstance(java.lang.Object[]) (Constructor.java:430)
2020-10-28 10:38:24.764 5315-5315/? I/art:     at android.view.View android.view.LayoutInflater.createView(java.lang.String, java.lang.String, android.util.AttributeSet) (LayoutInflater.java:645)
2020-10-28 10:38:24.764 5315-5315/? I/art:     at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:787)
2020-10-28 10:38:24.764 5315-5315/? I/art:     at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet) (LayoutInflater.java:727)
2020-10-28 10:38:24.764 5315-5315/? I/art:     at void android.view.LayoutInflater.rInflate(org.xmlpull.v1.XmlPullParser, android.view.View, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:858)
2020-10-28 10:38:24.764 5315-5315/? I/art:     at void android.view.LayoutInflater.rInflateChildren(org.xmlpull.v1.XmlPullParser, android.view.View, android.util.AttributeSet, boolean) (LayoutInflater.java:821)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at android.view.View android.view.LayoutInflater.inflate(org.xmlpull.v1.XmlPullParser, android.view.ViewGroup, boolean) (LayoutInflater.java:518)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup, boolean) (LayoutInflater.java:426)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup) (LayoutInflater.java:377)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:607)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at void com.commonsware.cwac.preso.demo.service.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:28)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6720)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1119)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2618)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2726)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at void android.app.ActivityThread.-wrap12(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1477)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at void android.os.Looper.loop() (Looper.java:154)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6119)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:886)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:776)
2020-10-28 10:38:24.765 5315-5315/? I/art: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.commonsware.cwac.preso.demo.service-1/base.apk"],nativeLibraryDirectories=[/data/app/com.commonsware.cwac.preso.demo.service-1/lib/arm64, /system/lib64, /vendor/lib64]]
2020-10-28 10:38:24.765 5315-5315/? I/art:     at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:56)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:380)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at void androidx.core.view.ViewCompat.setBackground(android.view.View, android.graphics.drawable.Drawable) (ViewCompat.java:2341)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at void androidx.appcompat.widget.ActionBarContainer.<init>(android.content.Context, android.util.AttributeSet) (ActionBarContainer.java:62)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at java.lang.Object java.lang.reflect.Constructor.newInstance0!(java.lang.Object[]) (Constructor.java:-2)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at java.lang.Object java.lang.reflect.Constructor.newInstance(java.lang.Object[]) (Constructor.java:430)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at android.view.View android.view.LayoutInflater.createView(java.lang.String, java.lang.String, android.util.AttributeSet) (LayoutInflater.java:645)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:787)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet) (LayoutInflater.java:727)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at void android.view.LayoutInflater.rInflate(org.xmlpull.v1.XmlPullParser, android.view.View, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:858)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at void android.view.LayoutInflater.rInflateChildren(org.xmlpull.v1.XmlPullParser, android.view.View, android.util.AttributeSet, boolean) (LayoutInflater.java:821)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at android.view.View android.view.LayoutInflater.inflate(org.xmlpull.v1.XmlPullParser, android.view.ViewGroup, boolean) (LayoutInflater.java:518)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup, boolean) (LayoutInflater.java:426)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup) (LayoutInflater.java:377)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:607)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at void com.commonsware.cwac.preso.demo.service.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:28)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6720)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1119)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2618)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2726)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at void android.app.ActivityThread.-wrap12(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1477)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at void android.os.Looper.loop() (Looper.java:154)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6119)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:886)
2020-10-28 10:38:24.765 5315-5315/? I/art:     at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:776)
2020-10-28 10:38:24.896 5315-5315/? D/AndroidRuntime: Shutting down VM
2020-10-28 10:38:24.910 5315-5315/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.commonsware.cwac.preso.demo.service, PID: 5315
    java.lang.RuntimeException: Unable to create service com.commonsware.cwac.preso.demo.service.SlideshowService: android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRootImpl$W@7d96dcf -- permission denied for window type 2003
        at android.app.ActivityThread.handleCreateService(ActivityThread.java:3201)
        at android.app.ActivityThread.-wrap5(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1567)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6119)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
     Caused by: android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRootImpl$W@7d96dcf -- permission denied for window type 2003
        at android.view.ViewRootImpl.setView(ViewRootImpl.java:706)
        at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:348)
        at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:94)
        at com.commonsware.cwac.preso.PresentationService.showPreso(PresentationService.java:104)
        at com.commonsware.cwac.preso.PresentationHelper.handleRoute(PresentationHelper.java:133)
        at com.commonsware.cwac.preso.PresentationHelper.onResume(PresentationHelper.java:70)
        at com.commonsware.cwac.preso.PresentationService.onCreate(PresentationService.java:79)
        at com.commonsware.cwac.preso.demo.service.SlideshowService.onCreate(SlideshowService.java:51)
        at android.app.ActivityThread.handleCreateService(ActivityThread.java:3191)
        at android.app.ActivityThread.-wrap5(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1567) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:154) 
        at android.app.ActivityThread.main(ActivityThread.java:6119) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) 

any idea hot to fix or better diagnose ?

Thanks Tom.

How to get the secondary screen touch event

I want to touch both local screen and secondary screen. I have try to run the demo app, and connect a mouse. But I cannot move the mouse to the secondary screen.

Is anybody know why?

Thankyou for read!

UI Size isssus

Hi,my android phone connect a 640*400 screen.Everything is very well except that when I use dp or sp with two different phones,the size of the views are different.And I used the PresentationService's buildPresoView method params inflater to inflate my views.How to match second screen ui between different phones? Thank you~

secondary screen display issue

Hello, I use the PresentationService to display a view on a screen(can touch).
When I touch the view's child view to move position, but the screen has smear,

When I change the targetSdkVersion to "17", it display with no issue.

Do you know why, thanks!

Show more on Mirror fragment

Wow! This lib is very useful for me. I have a question. I am trying mirror part of my layout on virtual display. Meanwhile, I need the virtual display to show more views. So how should I do? Please give me some help. Thank you~

Presentation surface of presentation service is destroyed when terminating the parent application

This problem occurs when an app contains both an activity and a presentation service. When terminating the activity(app) then the presentation service's surface is destroyed.

I've observed this problem in my own application but it also occurs with the demoService application.
Android OS version: 7.0

Bringing the app to the background works correctly, only destroying the app triggers this behavior.
The presentation service is automatically restarted after 1 sec, after which it works correctly.

Error captured with adb logcat
12-20 15:31:20.326 3713 7220 I WindowManager_SurfaceController: Destroying surface Surface(name=com.android.systemui/com.android.systemui.recents.RecentsActivity) called by com.android.server.wm.WindowStateAnimator.destroySurface:2840 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:1070 com.android.server.wm.WindowState.destroyOrSaveSurface:2561 com.android.server.wm.AppWindowToken.destroySurfaces:412 com.android.server.wm.AppWindowToken.destroySurfaces:376 com.android.server.wm.AppWindowToken.notifyAppStopped:456 com.android.server.wm.WindowManagerService.notifyAppStopped:5199

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.