[F/OS] 🥅 NetworkUtilities - Some Tools To Do With Network

Di mana saya bisa ambil yang baru

Versi 2 link download?

Thanks for reminding and sorry for the delay, uploading it now.

EDIT: Uploaded it now.

ok i will wait

Already uploaded, no need to wait. :slightly_smiling_face:

1 Like

is it in the old download link?

No Rommi, I replaced the old download link. Refresh your browser and check it again.

can you give an example of block get ip address

Please add wifi enable and disable function.

Already available in this extension by Taifun. Please search first.

This extension not working.

Did you read this?

Hello Gordon,
remember me long time no talk
anyways I've been looking for an extension that can track mobile data usage, I haven't found anything, I hope you can add that. And also wifi usage, turn wifi on, off.
Thank you,
Joshua

Already asked ...

I don't think it makes sense to do many similar extensions. Therefore, if you wish, you can add this code to your extension. Some methods that may come in handy. Data usage is counted from the last time the phone was turned on. Download and upload speed shows in KB/s, data volume in Bytes.

public class DataUsageMonitor extends AndroidNonvisibleComponent {
    private long mStartRX, mStartTX;
    private Handler mHandler;
    private Runnable mRunnable;

    public DataUsageMonitor(ComponentContainer container) {
        super(container.$form());
        mHandler = new Handler();
        startMonitoring();
    }

    public void startMonitoring() {
        mStartRX = TrafficStats.getTotalRxBytes();
        mStartTX = TrafficStats.getTotalTxBytes();
        mRunnable = new Runnable() {
            @Override
            public void run() {
                long rxBytes = TrafficStats.getTotalRxBytes() - mStartRX;
                long txBytes = TrafficStats.getTotalTxBytes() - mStartTX;
                double rxSpeed = rxBytes / 1024.0;
                double txSpeed = txBytes / 1024.0;
                Monitoring(rxSpeed, txSpeed);
                mStartRX = TrafficStats.getTotalRxBytes();
                mStartTX = TrafficStats.getTotalTxBytes();
                mHandler.postDelayed(this, 1000);
            }
        };
        mHandler.postDelayed(mRunnable, 1000);
    }

    @SimpleEvent(description = "")
    public void Monitoring(double rxSpeed, double txSpeed) {
        EventDispatcher.dispatchEvent(this, "Monitoring", rxSpeed, txSpeed);
    }

    @SimpleProperty(description = "")
    public long TotalRxUsage() {
        return TrafficStats.getTotalRxBytes();
    }

    @SimpleProperty(description = "")
    public long TotalTxUsage() {
        return TrafficStats.getTotalTxBytes();
    }

    @SimpleProperty(description = "")
    public long MobileRxUsage() {
        return TrafficStats.getMobileRxBytes();
    }

    @SimpleProperty(description = "")
    public long MobileTxUsage() {
        return TrafficStats.getMobileTxBytes();
    }

Permission required:

android.permission.ACCESS_NETWORK_STATE

Import:

import android.net.TrafficStats;
import android.os.Handler;
1 Like

Hi Joshua. Did you ever find a way of tracking mobile data usage?
Many thanks.
Nigel

You can see if this is enough:

1 Like

Hi Patryk. Many thanks for your quick answer. I will have a look at this and see if I can use it somehow. My phone shows data used since my last billing period and I would like my app to tap into that so it can then roughly calculate what the balance of my data allowance is, so I can see through the app if the balance is getting low.

This may not be possible because only system apps with special permissions have access to the total data usage history. Which is strange because in my opinion data consumption is not particularly sensitive information.

Hi Patryk. Ah, many thanks for the explanation which is very helpful.