Java Question Where Am I wrong?

FabioG

Active Member
Licensed User
Longtime User
Hello,

I'm trying to create my first library
but something is wrong ...

could you tell me where I'm wrong?
Who can help me?

B4X:
package net.snclabs.LightNotify;


import anywheresoftware.b4a.BA.ShortName;
import android.content.BroadcastReceiver;
import android.content.Intent;

@ShortName("LightNotify")

public class LightNotify {

   private String PackageName2;
   
   public void Initialize(String PackageName) {
      PackageName2 = PackageName;
   }
   
   public void NotifyAdd(String NotificationText, String TextToShow) {
      Intent intent = new Intent(PackageName2);      
      intent.putExtra(NotificationText, TextToShow);
      context.sendBroadcast(intent);

      
   }
   
   public void NotifyClear() {
      Intent intent = new Intent(PackageName2 + ".CLEARED_NOTIFICATION");
      context.sendBroadcast(intent);
      
   }
   
   public void SwippingMethod() {
      Intent deleteIntent = new Intent(context,NotificationReceiver.class);
       notification.deleteIntent = PendingIntent.getBroadcast(context,0,deleteIntent, 0);
   }

   public class NotificationReceiver extends BroadcastReceiver {
       @Override
      public void onReceive(Context context, Intent intent) {
         Intent intent1 = new Intent(PackageName2 + ".CLEARED_NOTIFICATION");
          context.sendBroadcast(intent1);
      }
}

}
 

FabioG

Active Member
Licensed User
Longtime User
Which error do you get?

but I lacked the references are corrected

But now when I load the library in Basic4Android visualize the error that I enclose with the image.

how can I fix?

thanks
Fabio

B4X:
package net.snclabs.LightNotify;

import anywheresoftware.b4a.BA.ShortName;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.app.Notification;
import android.app.PendingIntent;

@ShortName("LightNotify")

public class LightNotify {

   /**
    * Test LightNotify
    */
   
   private static Context context;
    private static Notification notification;

   public String PackageName2;
   
   public void Initialize(String PackageName) {
      PackageName2 = PackageName;
   }
   
   public void NotifyAdd(String NotificationText, String TextToShow) {
      Intent intent = new Intent(PackageName2);      
      intent.putExtra(NotificationText, TextToShow);
      context.sendBroadcast(intent);
      
      
   }
   
   public void NotifyClear() {
      Intent intent = new Intent(PackageName2 + ".CLEARED_NOTIFICATION");
      context.sendBroadcast(intent);
      
   }
   
   public void SwippingMethod() {   
      Intent deleteIntent = new Intent(context,NotificationReceiver.class);
       notification.deleteIntent = PendingIntent.getBroadcast(context,0,deleteIntent, 0);
   }
   
   public class NotificationReceiver extends BroadcastReceiver {
       @Override
      public void onReceive(Context context, Intent intent) {
         Intent intent1 = new Intent(PackageName2 + ".CLEARED_NOTIFICATION");
          context.sendBroadcast(intent1);
      }
   }
   
   
}
 

Attachments

  • Error.png
    Error.png
    17.9 KB · Views: 302

FabioG

Active Member
Licensed User
Longtime User
B4X:
@Hide
public class NotificationReceiver extends BroadcastReceiver {
        @Override        
       public void onReceive(Context context, Intent intent) {
          Intent intent1 = new Intent(PackageName2 + ".CLEARED_NOTIFICATION");
           context.sendBroadcast(intent1);
       }
    }

perfect!

Thank you very much :)
 
Top