B4A Library Notification Builder Library.

barx

Well-Known Member
Licensed User
Longtime User
Hmmmm I will recompile when I get home. Should be up in an hour or so...
 

barx

Well-Known Member
Licensed User
Longtime User
Thank u man
Try this one. No idea what happened before. The .xml didn't construct properly.

The NotificationCustomLayout object seems to show in B4A now
 

Attachments

  • NotificationBuilderLibFilesV303.zip
    21 KB · Views: 320

Mrjoey

Active Member
Licensed User
Longtime User
Try this one. No idea what happened before. The .xml didn't construct properly.

The NotificationCustomLayout object seems to show in B4A now
tried and setvisibility has no effect for all int values !
 

barx

Well-Known Member
Licensed User
Longtime User
Dim cl As NotificationCustomLayout , is not found and colored red
Not sure what else I can do then I'm afraid. I use the remoteViews method which will most likely be the same as the remoteViews object

the code in the library is

B4X:
    public void SetVisibility(String View, int Visibility) {
        ((RemoteViews)getObject()).setViewVisibility(BA.applicationContext.getResources().getIdentifier(View, "id", BA.packageName), Visibility);
    }

Would it work good enough to create different layouts for the differing states and recreate the notification when required to change?
 

barx

Well-Known Member
Licensed User
Longtime User
In fact, just thinking. once you change the visibility repeat

B4X:
n.CustomLayout = cl

'or (depending which you originally set

n.BigCustomLayout = cl

then call .notify again
with the same id as original

See if that does the trick.

It basically should update the custom layout on the notification.
 

Mrjoey

Active Member
Licensed User
Longtime User
here is my code :
B4X:
    cl.SetTextField("Title",Cursor1.GetString("Title"))
    cl.SetTextField("Artist",Cursor1.GetString("Artist"))
    cl.SetVisibility("Play",2)
    Nbuild.BigCustomLayout = cl.BuildLayout
    Nbuild.Notify(1)
cl and nbuild are intialized when the service is created.
here is my xml but i dont think it is the problem :
B4X:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="140dp"
    android:gravity="center_horizontal" >

    <ImageView
        android:id="@+id/Image"
        android:layout_width="140dp"
        android:layout_height="140dp"
        android:scaleType="fitCenter" />

    <TextView
        android:id="@+id/Title"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:layout_marginLeft="140dp"
        android:gravity="center_horizontal"
        android:text="Title"
        android:textSize="16sp"
        android:textStyle="normal|bold"
        android:typeface="serif" />

    <TextView
        android:id="@+id/Artist"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:layout_marginLeft="140dp"
        android:layout_marginTop="40dp"
        android:gravity="center_horizontal"
        android:text="Artist"
        android:textSize="16sp"
        android:textStyle="bold"
        android:typeface="serif" />

    <Button
        android:id="@+id/Prev"
        android:layout_width="40dp"
        android:layout_height="20dp"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="2dp"
        android:layout_marginLeft="10dp"
        android:layout_toRightOf="@+id/Image"
        android:background="@drawable/btnprevious" />

    <Button
        android:id="@+id/Next"
        android:layout_width="40dp"
        android:layout_height="20dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_marginBottom="2dp"
        android:layout_marginRight="10dp"
        android:background="@drawable/btnnext"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignBottom="@+id/Next"
        android:layout_alignTop="@id/Next"
        android:layout_marginBottom="2dp"
        android:layout_toLeftOf="@+id/Next"
        android:layout_toRightOf="@+id/Prev"
        android:orientation="horizontal" >

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >

            <Button
                android:id="@+id/Play"
                android:layout_width="22dp"
                android:layout_height="match_parent"
                android:layout_centerHorizontal="true"
                android:background="@drawable/btnplay" />

        </RelativeLayout>

    </LinearLayout>

</RelativeLayout>
 

Mrjoey

Active Member
Licensed User
Longtime User

B4X:
((RemoteViews)getObject())
excuse my little knowledge in java but do u think that this line has no effect? because i think u redim it and still has no resource , like when u say :
B4X:
dim A as object
but A still not assigned to any object?
 

barx

Well-Known Member
Licensed User
Longtime User
This class uses AbsObjectWrapper. This is the way you access the object. All the methods use similar syntax. For example setTextField looks like

B4X:
    public void SetTextField(String TextField, String Text) {
        ((RemoteViews)getObject()).setTextViewText(BA.applicationContext.getResources().getIdentifier(TextField, "id", BA.packageName), Text);
    }
 

Mrjoey

Active Member
Licensed User
Longtime User
aha then what do u suggest me to try now?
 

barx

Well-Known Member
Licensed User
Longtime User
Currently out of ideas
 

barx

Well-Known Member
Licensed User
Longtime User
me too , anyway thanks man for today we both are tired for now , i will start tomorrow and any updates we will discuss it tomorrow , good evening
Found some new values for visibility. Try

8 for GONE
4 for INVISIBLE
 

barx

Well-Known Member
Licensed User
Longtime User
Brilliant. Very happy that it now works. We got there in the end lol
 

Mrjoey

Active Member
Licensed User
Longtime User
hey , quick question , when calling setimage on custom notificatification , the app freezes for a while , is that normal?
 

barx

Well-Known Member
Licensed User
Longtime User
hey , quick question , when calling setimage on custom notificatification , the app freezes for a while , is that normal?

I've never really done much with images. Maybe it's due to size of the image?? I honestly have no idea sorry. the method in my library simply wraps the standard Android api method.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…