I'm trying to complete the following code lab using Xamarin.Android: https://codelabs.developers.google.com/codelabs/Material-Design-Style/#0
However, the collapsing toolbar is very laggy. When scrolling down I have to wait more than a full second for the app to catch up and show the updated (collapsed) toolbar. CPU usage during this time is 100%. Starting the DetailActivity also takes much longer than normal. The image I'm trying to load is a bit over 3 MB in size.
Layout file (activity_detail.axml):
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/detail_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="#dimen/app_bar_height"
android:fitsSystemWindows="true"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:theme="#style/ThemeOverlay.AppCompat.Dark"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="#dimen/article_keylines"
app:expandedTitleMarginStart="#dimen/md_keylines"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="#+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/paris"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="#dimen/article_keylines"
android:paddingRight="#dimen/md_keylines"
android:paddingTop="#dimen/md_keylines">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="?attr/colorAccent"
android:text="Description"
android:textSize="#dimen/md_keylines"
android:layout_marginBottom="#dimen/md_keylines" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/detail_desc" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="?attr/colorAccent"
android:text="Location"
android:textSize="#dimen/article_titles"
android:layout_marginBottom="#dimen/md_keylines"
android:layout_marginTop="#dimen/md_keylines" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/detail_location" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
DetailActivity.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Support.Design.Widget;
using Android.Views;
using Android.Widget;
using Android.Support.V7.App;
using Android.Support.V7.Widget;
using Toolbar = Android.Support.V7.Widget.Toolbar;
namespace MaterialDesign
{
[Activity(ParentActivity = typeof(MainActivity))]
public class DetailActivity : AppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.activity_detail);
SetSupportActionBar(FindViewById<Toolbar>(Resource.Id.toolbar));
SupportActionBar.SetDisplayHomeAsUpEnabled(true);
CollapsingToolbarLayout collapsingToolbar =
FindViewById<CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar);
collapsingToolbar.Title = GetString(Resource.String.item_title);
}
}
}
I also made this app native in Java using Android Studio and everything runs smooth there.
NOTE: The layout file is exactly the same as the one in the Android Studio project.
Any ideas what the problem could be?
UPDATE: I noticed that the app just crashes on devices with less memory than the ones I tested the app on (out of memory exception). This is the stack trace:
...
04-07 08:01:47.373 1193-1193/MaterialDesign.MaterialDesign D/Mono: Assembly Ref addref MaterialDesign[0xb9648460] -> Xamarin.Android.Support.v7.RecyclerView[0xb9634dc8]: 2
04-07 08:01:47.373 1193-1193/MaterialDesign.MaterialDesign D/Mono: Assembly Ref addref Xamarin.Android.Support.v7.RecyclerView[0xb9634dc8] -> Xamarin.Android.Support.v4[0xb9633e58]: 5
04-07 08:01:47.409 1193-1193/MaterialDesign.MaterialDesign D/libEGL: loaded /system/lib/egl/libEGL_genymotion.so
04-07 08:01:47.417 1193-1193/MaterialDesign.MaterialDesign D/libEGL: loaded /system/lib/egl/libGLESv1_CM_genymotion.so
04-07 08:01:47.421 1193-1193/MaterialDesign.MaterialDesign D/libEGL: loaded /system/lib/egl/libGLESv2_genymotion.so
04-07 08:01:47.457 1193-1193/MaterialDesign.MaterialDesign W/EGL_genymotion: eglSurfaceAttrib not implemented
04-07 08:01:47.473 1193-1193/MaterialDesign.MaterialDesign D/OpenGLRenderer: Enabling debug mode 0
04-07 08:01:47.493 1193-1195/MaterialDesign.MaterialDesign D/dalvikvm: GC_CONCURRENT freed 184K, 3% free 11139K/11463K, paused 11ms+0ms, total 14ms
04-07 08:01:47.493 1193-1193/MaterialDesign.MaterialDesign D/dalvikvm: GC_FOR_ALLOC freed 6K, 3% free 11136K/11463K, paused 3ms, total 3ms
04-07 08:01:47.497 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm-heap: Grow heap (frag case) to 12.511MB for 1638412-byte allocation
04-07 08:01:47.521 1193-1195/MaterialDesign.MaterialDesign D/dalvikvm: GC_CONCURRENT freed <1K, 3% free 12736K/13127K, paused 11ms+12ms, total 25ms
04-07 08:01:47.561 1193-1193/MaterialDesign.MaterialDesign D/dalvikvm: GC_FOR_ALLOC freed 0K, 3% free 12736K/13127K, paused 2ms, total 2ms
04-07 08:01:47.573 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm-heap: Grow heap (frag case) to 18.761MB for 6553612-byte allocation
04-07 08:01:47.609 1193-1195/MaterialDesign.MaterialDesign D/dalvikvm: GC_CONCURRENT freed 0K, 3% free 19136K/19591K, paused 11ms+0ms, total 36ms
04-07 08:01:47.717 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: Could not find method android.support.v7.widget.LinearLayoutCompat.drawableHotspotChanged, referenced from method android.support.design.internal.ForegroundLinearLayout.drawableHotspotChanged
04-07 08:01:47.717 1193-1193/MaterialDesign.MaterialDesign W/dalvikvm: VFY: unable to resolve virtual method 14829: Landroid/support/v7/widget/LinearLayoutCompat;.drawableHotspotChanged (FF)V
04-07 08:01:47.717 1193-1193/MaterialDesign.MaterialDesign D/dalvikvm: VFY: replacing opcode 0x6f at 0x0000
04-07 08:01:47.729 1193-1193/MaterialDesign.MaterialDesign D/Mono: Assembly Ref addref Xamarin.Android.Support.v7.AppCompat[0xb9621c20] -> System.Core[0xb9705298]: 3
04-07 08:01:47.789 1193-1193/MaterialDesign.MaterialDesign D/OpenGLRenderer: TextureCache::get: create texture(0xb9633ef0): name, size, mSize = 2, 9216, 9216
04-07 08:01:47.805 1193-1193/MaterialDesign.MaterialDesign D/OpenGLRenderer: TextureCache::get: create texture(0xb98f1880): name, size, mSize = 3, 9216, 18432
04-07 08:01:48.033 1193-1193/MaterialDesign.MaterialDesign D/OpenGLRenderer: TextureCache::get: create texture(0xb98da550): name, size, mSize = 4, 6553600, 6572032
04-07 08:01:48.097 1193-1193/MaterialDesign.MaterialDesign D/OpenGLRenderer: TextureCache::get: create texture(0xb95fafd8): name, size, mSize = 7, 1600, 6573632
04-07 08:01:48.321 1193-1193/MaterialDesign.MaterialDesign D/OpenGLRenderer: TextureCache::get: create texture(0xb98486b8): name, size, mSize = 13, 9216, 6582848
04-07 08:01:48.321 1193-1193/MaterialDesign.MaterialDesign D/OpenGLRenderer: TextureCache::get: create texture(0xb960b438): name, size, mSize = 14, 4096, 6586944
04-07 08:01:48.357 1193-1193/MaterialDesign.MaterialDesign I/Choreographer: Skipped 36 frames! The application may be doing too much work on its main thread.
04-07 08:02:41.493 1193-1193/MaterialDesign.MaterialDesign D/OpenGLRenderer: TextureCache::get: create texture(0xb95ef230): name, size, mSize = 222, 1127520, 7714464
04-07 08:02:41.505 1193-1193/MaterialDesign.MaterialDesign D/OpenGLRenderer: TextureCache::get: create texture(0xb95ee6e8): name, size, mSize = 223, 100224, 7814688
04-07 08:02:47.293 1193-1193/MaterialDesign.MaterialDesign D/OpenGLRenderer: TextureCache::get: create texture(0xb95e7f10): name, size, mSize = 345, 576, 7815264
04-07 08:02:47.401 1193-1193/MaterialDesign.MaterialDesign D/dalvikvm: GC_FOR_ALLOC freed 1797K, 10% free 17775K/19655K, paused 5ms, total 5ms
04-07 08:02:47.405 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm-heap: Grow heap (frag case) to 28.633MB for 11746016-byte allocation
04-07 08:02:47.421 1193-1195/MaterialDesign.MaterialDesign D/dalvikvm: GC_CONCURRENT freed 13K, 7% free 29232K/31175K, paused 11ms+0ms, total 14ms
04-07 08:02:47.597 1193-1193/MaterialDesign.MaterialDesign D/dalvikvm: GC_FOR_ALLOC freed 0K, 7% free 29232K/31175K, paused 2ms, total 2ms
04-07 08:02:47.597 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm-heap: Forcing collection of SoftReferences for 46984028-byte allocation
04-07 08:02:47.601 1193-1193/MaterialDesign.MaterialDesign D/dalvikvm: GC_BEFORE_OOM freed 9K, 7% free 29222K/31175K, paused 6ms, total 6ms
04-07 08:02:47.601 1193-1193/MaterialDesign.MaterialDesign E/dalvikvm-heap: Out of memory on a 46984028-byte allocation.
04-07 08:02:47.601 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: "main" prio=5 tid=1 RUNNABLE
04-07 08:02:47.601 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: | group="main" sCount=0 dsCount=0 obj=0xa622e4b0 self=0xb951e510
04-07 08:02:47.601 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: | sysTid=1193 nice=0 sched=0/0 cgrp=[fopen-error:2] handle=-1217354688
04-07 08:02:47.601 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: | schedstat=( 2330495687 1274137896 5442 ) utm=171 stm=61 core=0
04-07 08:02:47.601 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
04-07 08:02:47.601 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:500)
04-07 08:02:47.601 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:353)
04-07 08:02:47.601 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:781)
04-07 08:02:47.601 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at android.content.res.Resources.loadDrawable(Resources.java:1930)
04-07 08:02:47.601 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
04-07 08:02:47.601 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at android.view.View.<init>(View.java:3336)
04-07 08:02:47.601 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at android.widget.ImageView.<init>(ImageView.java:114)
04-07 08:02:47.601 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:58)
04-07 08:02:47.601 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:54)
04-07 08:02:47.601 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:95)
04-07 08:02:47.601 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at android.support.v7.app.AppCompatDelegateImplV7.createView(AppCompatDelegateImplV7.java:938)
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:992)
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:675)
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:256)
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at md5cdedf066eabae933cf5b8144b87f883b.DetailActivity.n_onCreate(Native Method)
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at md5cdedf066eabae933cf5b8144b87f883b.DetailActivity.onCreate(DetailActivity.java:28)
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at android.app.Activity.performCreate(Activity.java:5008)
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at android.app.ActivityThread.access$600(ActivityThread.java:130)
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at android.os.Handler.dispatchMessage(Handler.java:99)
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at android.os.Looper.loop(Looper.java:137)
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at android.app.ActivityThread.main(ActivityThread.java:4745)
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at java.lang.reflect.Method.invokeNative(Native Method)
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at java.lang.reflect.Method.invoke(Method.java:511)
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign I/dalvikvm: at dalvik.system.NativeStart.main(Native Method)
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: Stacktrace:
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at <unknown> <0xffffffff>
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at (wrapper managed-to-native) object.wrapper_native_0xb66e1b90 (intptr,intptr,intptr,intptr,Android.Runtime.JValue*) <0xffffffff>
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue*) <0x0008d>
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at Android.App.Activity.SetContentView (int) <0x0014f>
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at MaterialDesign.DetailActivity.OnCreate (Android.OS.Bundle) <0x0002e>
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at Android.Support.V4.App.FragmentActivity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) <0x00057>
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at (wrapper dynamic-method) object.f3681e7a-16a5-436b-bfa3-c04082252994 (intptr,intptr,intptr) <0x00027>
04-07 08:02:47.605 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at (wrapper native-to-managed) object.f3681e7a-16a5-436b-bfa3-c04082252994 (intptr,intptr,intptr) <0xffffffff>
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+377510 [0xb6d302a6]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+354302 [0xb6d2a7fe]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+440759 [0xb6d3f9b7]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+410143 [0xb6d3821f]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+837579 [0xb6da07cb]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+838916 [0xb6da0d04]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+567193 [0xb6d5e799]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+574224 [0xb6d60310]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+535528 [0xb6d56be8]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+490340 [0xb6d4bb64]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+462504 [0xb6d44ea8]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+471496 [0xb6d471c8]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+669154 [0xb700b5e2]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+671378 [0xb700be92]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+110240 [0xb66b6ea0]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+395513 [0xb66fc8f9]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+811016 [0xb6762008]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+168966 [0xb66c5406]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+157136 [0xb66c25d0]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+595124 [0xb672d4b4]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+385144 [0xb66fa078]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+285799 [0xb66e1c67]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+80308 [0x9302f9b4]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+79742 [0x9302f77e]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+128672 [0x9303b6a0]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+169583 [0x9304566f]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+126736 [0x9303af10]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+288 [0x93053120]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+91608 [0x930325d8]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+110240 [0xb66b6ea0]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+395513 [0xb66fc8f9]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+811016 [0xb6762008]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+168966 [0xb66c5406]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+157136 [0xb66c25d0]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+594202 [0xb672d11a]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+663802 [0xb673e0fa]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+811016 [0xb6762008]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+168966 [0xb66c5406]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+157136 [0xb66c25d0]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+595833 [0xb672d779]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+403306 [0xb66fe76a]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+344986 [0xb6fbc39a]
04-07 08:02:47.609 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+349705 [0xb6fbd609]
04-07 08:02:47.613 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+4599 [0xb770c1f7]
04-07 08:02:47.613 1193-1193/MaterialDesign.MaterialDesign E/mono-rt: at ???+94767 [0xb750022f]
04-07 08:02:47.613 1193-1193/MaterialDesign.MaterialDesign A/libc: Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 1193 (.MaterialDesign)
Line 28 in DetailActivity is this one:
SetContentView(Resource.Layout.activity_detail);
try to set Java heap size to 1G
Right click on project -> Options -> Android Builds -> Advanced
i just added AdMob to my app. Everything seem to work well when i debug or install release version of app (HTC m7). The problem occurs on CHUWI VX2 device (esky82_tb_cn_kk, Android 4.4). It is very strange because on this device my App works in debug mode but doesn't works in release version. I try turn of pro-gourd but it doesn't help me.
Any one have idea for that?
my manifest
instruction inside my onCreate method:
mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.setAdListener(new AdListener() {
#Override
public void onAdClosed() {
super.onAdClosed();
mAdView.setVisibility(View.GONE);
}
#Override
public void onAdOpened() {
super.onAdOpened();
mAdView.startAnimation(fade_in);
mAdView.setVisibility(View.VISIBLE);
}
#Override
public void onAdFailedToLoad(int errorCode) {
super.onAdFailedToLoad(errorCode);
mAdView.setVisibility(View.GONE);
}
#Override
public void onAdLoaded() {
super.onAdLoaded();
mAdView.startAnimation(fade_in);
mAdView.setVisibility(View.VISIBLE);
}
#Override
public void onAdLeftApplication() {
super.onAdLeftApplication();
mAdView.setVisibility(View.GONE);
}
});
mAdView.loadAd(adRequest);
code inside layout.xml
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<com.google.android.gms.ads.AdView android:id="#+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:adSize="SMART_BANNER"
ads:adUnitId="#string/banner_ad_unit_id"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:visibility="gone">
</com.google.android.gms.ads.AdView>
</RelativeLayout>
Crash log:
05-01 19:39:16.305 124-124/? I/SurfaceFlinger﹕ Skip composition for [Built-in Screen (type:0)] since dirtyRegion is empty
05-01 19:39:16.321 124-124/? I/SurfaceFlinger﹕ Skip composition for [Built-in Screen (type:0)] since dirtyRegion is empty
05-01 19:39:16.330 2162-2162/? D/AndroidRuntime﹕ Shutting down VM
05-01 19:39:16.330 2162-2162/? W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41d79c98)
05-01 19:39:16.330 2162-2162/? W/dalvikvm﹕ threadid=1: uncaught exception occurred
05-01 19:39:16.331 2162-2162/? W/System.err﹕ java.lang.RuntimeException: Unable to start activity ComponentInfo{freshfrog.pytomat/freshfrog.pytomat.Main}: java.lang.NullPointerException
05-01 19:39:16.332 2162-2162/? W/System.err﹕ at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2338)
05-01 19:39:16.332 2162-2162/? W/System.err﹕ at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
05-01 19:39:16.332 2162-2162/? W/System.err﹕ at android.app.ActivityThread.access$800(ActivityThread.java:151)
05-01 19:39:16.332 2162-2162/? W/System.err﹕ at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
05-01 19:39:16.332 2162-2162/? W/System.err﹕ at android.os.Handler.dispatchMessage(Handler.java:110)
05-01 19:39:16.332 2162-2162/? W/System.err﹕ at android.os.Looper.loop(Looper.java:193)
05-01 19:39:16.333 2162-2162/? W/System.err﹕ at android.app.ActivityThread.main(ActivityThread.java:5292)
05-01 19:39:16.333 2162-2162/? W/System.err﹕ at java.lang.reflect.Method.invokeNative(Native Method)
05-01 19:39:16.333 2162-2162/? W/System.err﹕ at java.lang.reflect.Method.invoke(Method.java:515)
05-01 19:39:16.333 2162-2162/? W/System.err﹕ at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
05-01 19:39:16.333 2162-2162/? W/System.err﹕ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
05-01 19:39:16.333 2162-2162/? W/System.err﹕ at dalvik.system.NativeStart.main(Native Method)
05-01 19:39:16.334 2162-2162/? W/System.err﹕ Caused by: java.lang.NullPointerException
05-01 19:39:16.334 2162-2162/? W/System.err﹕ at freshfrog.pytomat.Main.onCreate(Main.java:450)
05-01 19:39:16.334 2162-2162/? W/System.err﹕ at android.app.Activity.performCreate(Activity.java:5264)
05-01 19:39:16.334 2162-2162/? W/System.err﹕ at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
05-01 19:39:16.334 2162-2162/? W/System.err﹕ at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302)
05-01 19:39:16.335 2162-2162/? W/System.err﹕ ... 11 more
05-01 19:39:16.335 2162-2162/? W/dalvikvm﹕ threadid=1: calling UncaughtExceptionHandler
05-01 19:39:16.336 124-124/? I/SurfaceFlinger﹕ Skip composition for [Built-in Screen (type:0)] since dirtyRegion is empty
05-01 19:39:16.339 2162-2162/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: freshfrog.pytomat, PID: 2162
java.lang.RuntimeException: Unable to start activity ComponentInfo{freshfrog.pytomat/freshfrog.pytomat.Main}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2338)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5292)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at freshfrog.pytomat.Main.onCreate(Main.java:450)
at android.app.Activity.performCreate(Activity.java:5264)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5292)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
at dalvik.system.NativeStart.main(Native Method)
05-01 19:39:16.341 654-669/? V/Provider/Settings﹕ from settings cache , name = dropbox:data_app_crash , value = null
05-01 19:39:16.342 654-669/? D/dalvikvm﹕ create interp thread : stack size=128KB
05-01 19:39:16.342 654-669/? D/dalvikvm﹕ create new thread
05-01 19:39:16.343 654-669/? D/dalvikvm﹕ new thread created
05-01 19:39:16.343 654-669/? D/dalvikvm﹕ update thread list
05-01 19:39:16.343 916-2188/? D/dalvikvm﹕ create interp thread : stack size=128KB
05-01 19:39:16.343 916-2188/? D/dalvikvm﹕ create new thread
05-01 19:39:16.343 916-2188/? D/dalvikvm﹕ new thread created
05-01 19:39:16.343 916-2188/? D/dalvikvm﹕ update thread list
05-01 19:39:16.343 654-2191/? D/dalvikvm﹕ threadid=82: interp stack at 0x64403000
05-01 19:39:16.343 654-2191/? D/dalvikvm﹕ threadid=82: created from interp
05-01 19:39:16.343 654-669/? D/dalvikvm﹕ start new thread
05-01 19:39:16.343 654-669/? V/Provider/Settings﹕ from settings cache , name = send_action_app_error , value = 1
05-01 19:39:16.343 654-669/? W/ActivityManager﹕ Force finishing activity freshfrog.pytomat/.Main
Logcat indicate this line (Main.java:450)
mAdView.setAdListener(new AdListener() {
what is this ?
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
what were you expecting? to hit both sides?
try this
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
and let the rest go
You are getting a NullPointerException on line 450 of Main.
Look at that line. Something there has not been initialised.
I solve my problem. This issue isn't connect with AdView. It was problem with project. I made small mistakes. I don't have this line
<?xml version="1.0" encoding="utf-8"?>
on the start of xml layout file. I don't know how it can event works.
I reboot device
I added missing line to xml
I clean project (Build > Clean Project)
I rebuild project (Build > Rebuild Project)
Then my apk starts work without progourd but crash when I enable this feature. So i find this solution
I configure progourd configuration file like this.
I am using Azure Mobile Service and call the post table service.
Record is created and return the object but I got the "Invalid length" json deserialization error as follow. May I know how to solve this issue.
02-10 00:45:31.613 2975-2981/com.takemetomyanmar.myanmarticket E/jdwp﹕ Failed sending reply to debugger: Broken pipe
02-10 00:46:11.553 2975-2975/com.takemetomyanmar.myanmarticket E/AMS﹕ Exception
com.google.gson.JsonParseException: Invalid length
at com.microsoft.windowsazure.mobileservices.DateSerializer.deserialize(DateSerializer.java:84)
at com.microsoft.windowsazure.mobileservices.DateSerializer.deserialize(DateSerializer.java:54)
at com.microsoft.windowsazure.mobileservices.DateSerializer.deserialize(DateSerializer.java:1)
at com.google.gson.TreeTypeAdapter.read(TreeTypeAdapter.java:58)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:93)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:172)
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:81)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:60)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:93)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:172)
at com.google.gson.Gson.fromJson(Gson.java:795)
at com.google.gson.Gson.fromJson(Gson.java:859)
at com.google.gson.Gson.fromJson(Gson.java:832)
at com.microsoft.windowsazure.mobileservices.JsonEntityParser.parseResults(JsonEntityParser.java:62)
at com.microsoft.windowsazure.mobileservices.MobileServiceTable.parseResults(MobileServiceTable.java:307)
at com.microsoft.windowsazure.mobileservices.MobileServiceTable.access$13(MobileServiceTable.java:305)
at com.microsoft.windowsazure.mobileservices.MobileServiceTable$ParseResultOperationCallback.onCompleted(MobileServiceTable.java:93)
at com.microsoft.windowsazure.mobileservices.MobileServiceJsonTable$2.onCompleted(MobileServiceJsonTable.java:249)
at com.microsoft.windowsazure.mobileservices.MobileServiceJsonTable$4.onPostExecute(MobileServiceJsonTable.java:389)
at com.microsoft.windowsazure.mobileservices.MobileServiceJsonTable$4.onPostExecute(MobileServiceJsonTable.java:1)
at android.os.AsyncTask.finish(AsyncTask.java:632)
at android.os.AsyncTask.access$600(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5050)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:806)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
at dalvik.system.NativeStart.main(Native Method)
I'm trying to accomplish Reading and Creating folders in the operations Own Cloud server through AsyncTask, login to the server with my credentials is done successfully, but when trying to create folders and read the following errors in the log is described below, which would be the possible reason for the error?
04-07 15:45:24.500: I/OwnCloud(31352): Sending File
04-07 15:45:24.510: I/OwnCloud(31352): Start Read Remote Folder
04-07 15:45:24.620: I/ReadRemoteFolderOperation(31352): Synchronized /: Operation finished with HTTP status code 207 (success)
04-07 15:45:24.630: I/OwnCloud(31352): Sending File
04-07 15:45:24.630: W/dalvikvm(31352): threadid=11: thread exiting with uncaught exception (group=0x40ffe438)
04-07 15:45:24.640: E/AndroidRuntime(31352): FATAL EXCEPTION: AsyncTask #1
04-07 15:45:24.640: E/AndroidRuntime(31352): java.lang.RuntimeException: An error occured while executing doInBackground()
04-07 15:45:24.640: E/AndroidRuntime(31352): at android.os.AsyncTask$3.done(AsyncTask.java:299)
04-07 15:45:24.640: E/AndroidRuntime(31352): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
04-07 15:45:24.640: E/AndroidRuntime(31352): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
04-07 15:45:24.640: E/AndroidRuntime(31352): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
04-07 15:45:24.640: E/AndroidRuntime(31352): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
04-07 15:45:24.640: E/AndroidRuntime(31352): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
04-07 15:45:24.640: E/AndroidRuntime(31352): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
04-07 15:45:24.640: E/AndroidRuntime(31352): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
04-07 15:45:24.640: E/AndroidRuntime(31352): at java.lang.Thread.run(Thread.java:856)
04-07 15:45:24.640: E/AndroidRuntime(31352): Caused by: java.lang.ArrayIndexOutOfBoundsException: length=5; index=5
04-07 15:45:24.640: E/AndroidRuntime(31352): at com.prologica.procamera.MainActivity$UploadPhotos.SendFolders(MainActivity.java:127)
04-07 15:45:24.640: E/AndroidRuntime(31352): at com.prologica.procamera.MainActivity$UploadPhotos.doInBackground(MainActivity.java:95)
04-07 15:45:24.640: E/AndroidRuntime(31352): at com.prologica.procamera.MainActivity$UploadPhotos.doInBackground(MainActivity.java:1)
04-07 15:45:24.640: E/AndroidRuntime(31352): at android.os.AsyncTask$2.call(AsyncTask.java:287)
04-07 15:45:24.640: E/AndroidRuntime(31352): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
04-07 15:45:24.640: E/AndroidRuntime(31352): ... 5 more
You have an array out of bound in com.prologica.procamera.MainActivity UploadPhotos.SendFolders(MainActivity.java:127). Check line 127 in MainActivity to make sure you are not going out of bounds. According to the log, the length is 5 and you are trying to access index 5(which does not exist)
I am creating a Worklight-based Hybrid application with the Android environment.
My application has push notifications configured. It is currently able to process incoming notifications and display the message payload in a pop-up box.
I would like to do the same in the native portion of the hybrid app (native pages initiated using WL.NativePage.show).
However, I'm encountering some problems when trying to get the Push object to register the registerEventSourceCallback handler.
What am I doing wrong?
Activity (Native page):
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WLClient client = WLClient.createInstance(this);
WLPush push = client.getPush(); // throws exception here
push.registerEventSourceCallback("myAndroid", "PushAdapter","PushEventSource", new PushNotificationListener() );
...
}
Exception:
04-07 09:37:39.552: E/AndroidRuntime(6562): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.Marinet/com.Marinet.HelloNative}: java.lang.IllegalArgumentException: Receiver not registered: com.google.android.gcm.GCMBroadcastReceiver#42648940
04-07 09:37:39.552: E/AndroidRuntime(6562): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2073)
04-07 09:37:39.552: E/AndroidRuntime(6562): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2098)
04-07 09:37:39.552: E/AndroidRuntime(6562): at android.app.ActivityThread.access$600(ActivityThread.java:138)
04-07 09:37:39.552: E/AndroidRuntime(6562): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1204)
04-07 09:37:39.552: E/AndroidRuntime(6562): at android.os.Handler.dispatchMessage(Handler.java:99)
04-07 09:37:39.552: E/AndroidRuntime(6562): at android.os.Looper.loop(Looper.java:137)
04-07 09:37:39.552: E/AndroidRuntime(6562): at android.app.ActivityThread.main(ActivityThread.java:4905)
04-07 09:37:39.552: E/AndroidRuntime(6562): at java.lang.reflect.Method.invokeNative(Native Method)
04-07 09:37:39.552: E/AndroidRuntime(6562): at java.lang.reflect.Method.invoke(Method.java:511)
04-07 09:37:39.552: E/AndroidRuntime(6562): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
04-07 09:37:39.552: E/AndroidRuntime(6562): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
04-07 09:37:39.552: E/AndroidRuntime(6562): at dalvik.system.NativeStart.main(Native Method)
04-07 09:37:39.552: E/AndroidRuntime(6562): Caused by: java.lang.IllegalArgumentException: Receiver not registered: com.google.android.gcm.GCMBroadcastReceiver#42648940
04-07 09:37:39.552: E/AndroidRuntime(6562): at android.app.LoadedApk.forgetReceiverDispatcher(LoadedApk.java:654)
04-07 09:37:39.552: E/AndroidRuntime(6562): at android.app.ContextImpl.unregisterReceiver(ContextImpl.java:1211)
04-07 09:37:39.552: E/AndroidRuntime(6562): at android.content.ContextWrapper.unregisterReceiver(ContextWrapper.java:378)
04-07 09:37:39.552: E/AndroidRuntime(6562): at com.google.android.gcm.GCMRegistrar.onDestroy(GCMRegistrar.java:266)
04-07 09:37:39.552: E/AndroidRuntime(6562): at com.worklight.wlclient.api.WLPush.unregisterReceivers(WLPush.java:654)
04-07 09:37:39.552: E/AndroidRuntime(6562): at com.worklight.wlclient.api.WLPush.<init>(WLPush.java:176)
04-07 09:37:39.552: E/AndroidRuntime(6562): at com.worklight.wlclient.api.WLClient.getPush(WLClient.java:673)
04-07 09:37:39.552: E/AndroidRuntime(6562): at com.Marinet.HelloNative.onCreate(HelloNative.java:53)
04-07 09:37:39.552: E/AndroidRuntime(6562): at android.app.Activity.performCreate(Activity.java:5244)
04-07 09:37:39.552: E/AndroidRuntime(6562): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1082)
04-07 09:37:39.552: E/AndroidRuntime(6562): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2037)
04-07 09:37:39.552: E/AndroidRuntime(6562): ... 11 more
Possible Solution:-
public class GCMIntentService extends com.worklight.androidgap.push.GCMIntentService {
#Override
protected void onMessage(Context context, Intent intent) {
if (!MyNativePage.isForeground()) {
// custom native page is not in foreground, handle it using existing WL methods
super.onMessage(context, intent);
} else {
// custom native page is in foreground, skip existing WL method and use custom method
MyNativePage.setNotificationMessage(intent.getExtras().getString("payload"));
}
}
}
Worklight contains 2 push implementations. One is for Hybrid apps and another is for Native apps using the Worklight Native API.
The two do not work together. This means that you cannot receive a notification in the Hybrid app >> navigate to a native page using WL.NativePage.show >> and then use the Worklight Native API for push to handle the received payload.
What you can you, is receive the notification in the Hybrid app and pass along its payload as you load the native page.
Passing data from Hybrid to Native is explained and demoed in the following training module:
Using native pages in hybrid applications
Sample project