Java Question Hide a some public method

Discussion in 'Libraries developers questions' started by mohsen nasrabady, May 10, 2015.

  1. mohsen nasrabady

    mohsen nasrabady Active Member Licensed User

    Hi this code is a cache cleaner that works perfectly and i want to publish this in forum
    the only problem is how can hide some public methods from B4A

    package anywheresoftware.b4a.cachecleaner;

    import java.util.ArrayList;
    import java.util.List;

    import com.frozendevs.cache.cleaner.model.AppsListItem;
    import com.frozendevs.cache.cleaner.model.CleanerService;

    import android.content.ComponentName;
    import android.content.Context;
    import android.content.Intent;
    import android.content.ServiceConnection;
    import android.os.Environment;
    import android.os.IBinder;
    import android.os.StatFs;
    import anywheresoftware.b4a.BA;
    import anywheresoftware.b4a.BA.Events;
    import anywheresoftware.b4a.BA.Permissions;
    import anywheresoftware.b4a.BA.ShortName;
    import anywheresoftware.b4a.BA.Version;

    @Events(values = { 
    "OnScanStarted","onScanProgress (Current As int , Total As int)","onScanCompleted (AppsList As Object)","onCleanStarted","onCleanCompleted (CacheSize As Long)" })
    @Permissions(values = {"android.permission.GET_PACKAGE_SIZE","android.permission.CLEAR_APP_CACHE"})

    public class CacheCleaner implements CleanerService.OnActionListener {
        CleanerService mCleanerService;
        private long totalmem;
        private long freemem;
        private boolean isinitialized = false;
        BA ba;
        String event;
        private ServiceConnection mServiceConnection = new ServiceConnection() {
            public void onServiceConnected(ComponentName name, IBinder service) {
                mCleanerService = ((CleanerService.CleanerServiceBinder) service).getService();
                isinitialized = true;



            public void onServiceDisconnected(ComponentName name) {
                mCleanerService = null;
                isinitialized = false;
        private ArrayList<Object> L;
        public void initialize(String EventName,final BA baa){
            ba = baa;
            event = EventName;
            BA.applicationContext.bindService(new Intent(BA.applicationContext.getApplicationContext(), CleanerService.class),
                mServiceConnection, Context.BIND_AUTO_CREATE);
        public void ScanCache(){
            if (mCleanerService != null && !mCleanerService.isScanning() &&
                    !mCleanerService.isCleaning()) {
        public void CleanCache(){
            if (mCleanerService != null && !mCleanerService.isScanning() &&
                    !mCleanerService.isCleaning() && mCleanerService.getCacheSize() > 0) {


        public void onScanStarted(Context context) {
            // TODO Auto-generated method stub
            BA.Log("Scan Started");
            ba.raiseEvent(this, event+"_onscanstarted",new Object[]{});

        public void onScanProgressUpdated(Context context, int current, int max) {
            // TODO Auto-generated method stub
            ba.raiseEvent(this, event+"_onscanprogress", new Object[]{current,max});

        public void onScanCompleted(Context context, List<AppsListItem> apps) {
            // TODO Auto-generated method stub
            int n;
            L = new ArrayList<>();
                AppsListItem item = apps.get(n);
                L.add(new Object[]{item.getApplicationName(),item.getPackageName(),item.getCacheSize(),item.getApplicationIcon()});
            ba.raiseEvent(this, event+"_onscancompleted", new Object[]{L});

        public void onCleanStarted(Context context) {
            // TODO Auto-generated method stub
            ba.raiseEvent(this, event+"_oncleanstarted", new Object[]{});

        public void onCleanCompleted(Context context, long cacheSize) {
            // TODO Auto-generated method stub
            ba.raiseEvent(this, event+"_oncleancompleted", new Object[]{cacheSize});
        private void updateStorageUsage() {
            StatFs stat = new StatFs(Environment.getDataDirectory().getAbsolutePath());

            totalmem = (long) stat.getBlockCount() * (long) stat.getBlockSize();
            long medMemory = mCleanerService != null ? mCleanerService.getCacheSize() : 0;
            long lowMemory = (long) stat.getAvailableBlocks() * (long) stat.getBlockSize();
            freemem = totalmem - medMemory - lowMemory;


    koaunglay likes this.
  2. Erel

    Erel Administrator Staff Member Licensed User

    Mark them with @Hide.
  3. mohsen nasrabady

    mohsen nasrabady Active Member Licensed User

    how exactly i am new in java
  4. DonManfred

    DonManfred Expert Licensed User

    To hide the sub subtohide use

    public void subtohide(){