Posts

Showing posts from April, 2021

How to set a Subtitle on ActionBar in Sketchware

Image
Open OnCreate event Now insert this code( View on Github ): getActionBar ( ) . setSubtitle ( "BYE" ) ; Alternatively, you can use( View on Github ): getSupportActionBar ( ) . setSubtitle ( "BYE" ) ; Done. You will now see Subtitle.

How to detect battery charging mode

Image
Steps to detect battery charging mode in Sketchware First of all, create a button in your Sketchware Project. Now paste the following code in button onClick( View on Github ): IntentFilter ifilter = new IntentFilter ( Intent . ACTION_BATTERY_CHANGED ); Intent batteryStatus = registerReceiver ( null , ifilter ); int chargePlug = batteryStatus . getIntExtra ( BatteryManager . EXTRA_PLUGGED ,- 1 ); boolean usbCharge = chargePlug == BatteryManager . BATTERY_PLUGGED_USB ; boolean acCharge = chargePlug == BatteryManager . BATTERY_PLUGGED_AC ; if ( usbCharge ){ /*BATTERY CHARGING THROUGH USB*/ Toast . makeText ( getApplicationContext (), "Device charging through USB" , Toast . LENGTH_LONG ). show (); } else if ( acCharge ) { /*BATTERY CHARGING THROUGH AC*/ Toast . makeText ( getApplicationContext (), "Device charging through AC" , Toast . LENGTH_LONG ). show (); } else { /*DEVICE NOT CHARGING*/ Toast . makeText ( getApplicationC...

Popular posts from this blog

How to make edittext in dialog in Sketchware

How to use request network for webview in Sketchware

How to make a browser in sketchware