• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps (Help) Pressing back on webview fragment activity does not go back to previous page

Hello.
I have an app that has fragment activities with webview and a navigational drawer. When I press back it goes to a previous fragment activity but it does not go back to the previous page on the webview.

The code on MainActivity.java:
Java:
 @Override
    public boolean onNavigationItemSelected(@NonNull MenuItem item) {
        switch (item.getItemId()) {
            case R.id.nav_facebook:
                getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
                        new FacebookFragment()).addToBackStack("tag").commit();
                break;
            case R.id.nav_twitter:
                getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
                        new TwitterFragment()).addToBackStack("tag").commit();
                break;
            case R.id.nav_instagram:
                getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
                        new InstagramFragment()).addToBackStack("tag").commit();
                break;
            case R.id.nav_linkedin:
                getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
                        new LinkedinFragment()).addToBackStack("tag").commit();
                break;
            case R.id.nav_snapchat:
                getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
                        new SnapchatFragment()).addToBackStack("tag").commit();
                break;
            case R.id.nav_pinterest:
                getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
                        new PinterestFragment()).addToBackStack("tag").commit();
                break;
            case R.id.nav_youtube:
                getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
                        new YoutubeFragment()).addToBackStack("tag").commit();
                break;
            case R.id.nav_about:
                getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
                        new AboutFragment()).addToBackStack("tag").commit();
                break;
            case R.id.nav_privacy:
                getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
                        new PrivacyFragment()).addToBackStack("tag").commit();
                break;
        }

        drawer.closeDrawer(GravityCompat.START);

        return true;
    }


    @Override
    public void onBackPressed() {
        FragmentManager fm = getSupportFragmentManager();
        if (fm.getBackStackEntryCount() > 0) {
            fm.popBackStack();
        } else {
            super.onBackPressed();
        }
    }

The code in one of the fragments (FacebookFragment.java):
Java:
public class FacebookFragment extends Fragment {
    public FacebookFragment() {

    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.fragment_facebook, container, false);
        WebView webView = (WebView)v.findViewById(R.id.webView);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.setWebViewClient(new WebViewClient());
        webView.loadUrl("https://www.facebook.com/");
        return v;



    }





}

StopMarker - You arrived!

GooglePlay: https://play.google.com/store/apps/details?id=com.soa.android.stopmarker

The program StopMarker can be useful for those who like taking a nap or reading in transport. Having marked on the map the destination point you can hide the program in the background and not worry about the route. You will not have to desperately check whether your destination is approaching behind the dark and frozen glass of the bus or train.

You can spend your time more pleasantly knowing that StopMarker will let you know when you arrive at your destination. The destination area can be adjusted, even if you do not know local roads. You will be notified as soon as you approach destination from any side. You could also use StopMarker when walking, riding on a bike or even taking a boat trip - StopMarker will work no matter what means of transportation you use.

It is very easy to start using StopMarker. After starting, Stopmarker will automatically display on the map your current location (a red marker). If no destination area is selected the green button appears to be deactivated.
You can adjust the scale of the map by moving your fingers or pressing the buttons "+" and "-" and moving the map on your screen to your destination point. If you press on the area where you want to arrive you will see a green marker with a circle around it. If the diameter of the destination area is small please make sure (visually) if your route crosses the destination area.

That is it! You can put the program in the background and start reading an interesting book or just close your eyes and have a nap.
After crossing the border of the destination area, the program will notify you by generating the specified number of sound signals. Also, in the notification bar you will see the "STOP" sign.
If you press the "OK" button that appears in the middle of the screen the signals will stop and the message will disappear.

__Important notes__

1) You need a working GPS (geolocation) in order to run this program on your smartphone.

2) You also need mobile internet access for caching the map of the area. If you do not have mobile internet, you can download the corresponding map in advance using WiFi - just start StopMarker and move the map on your screen to the area of your future route. In order to save a detailed map, use scaling by pressing "+" and "-" or zooming with your fingers. Each scale is stored separately on your smartphone. If you did not do this in advance, the scaling will not work offline and the map might look a bit rough.

3) If your smartphone is in the energy saving mode you should get a notification. In this mode with StopMarker running in the background there is a big chance of delay in GPS localization. It is better to deactivate the energy saving mode when using StopMarker or add the StopMarker program to the exceptions, following the instructions relevant for your smartphone.

4) Permissions for StopMarker - when installing the program, you will be asked to grant the permissions for accessing the geodata ("this device location") and the storage ("photos, media and files on your device"). In order to use the StopMarker's full functionality you should give the permissions in "any mode".
a) Access to geodata - required to enable the program running in the background.
b) Access to storage - required to let the program record the cached maps.
If you uninstall StopMarker, all the maps cached by it will be deleted from your smartphone.

5) In case of normal exit (swiping the program from the background), StopMarker will completely stop and will not occupy any resources.

6) If you shut down or reboot your smartphone, StopMarker will not start automatically. However, you can adjust the settings of your smartphone and add StopMarker to the list of programs that start automatically.

Attachments

Watch 3 and Blood Pressure

I've only had the Samsung Watch 3 for a few days. I like the watch and enjoy the fitness aspects of the watch.
With the associated health app on my phone I can track my heart rate, take an ECG, measure stress, and track my blood oxygen level. All of that is cool. However, I'm supposed to be able to take my blood pressure. The app is not on my watch and I can't find it to download. It is clearly a unit tracked by the phone app. Watching videos and reading up on the blood pressure app on the watch, I should simply navigate to the app and start the test. It is not on the watch to launch. I've checked for a watch update but I'm on the latest and greatest. It's a US watch purchased from Samsung. Anyone have a clue what's up?

A750g dead boot exynos 7885

Hello I have been working on dead boot repair for A750G was on U1, I tried splitting my appropriate sboot, but fails at part4 which is bootloader, transfer pass on bl1 bl2 and 3, could someone help me find correct offset for this device, currently am not even sure if my cfg file is correct. Here is my sboot bin am using https://drive.google.com/file/d/1CcEqe4MH__APK7H42aP3H2KGdqkAi-xx/view?usp=drivesdk

Help newly downloaded apps do not have an icon.

I must have changed a setting. Until recently, every time I install an app an icon for the app would appear on the last "page?" of apps. Now, when I install an app I do not get an icon anywhere. The app is definitely installed but I have to go to the "store," type the name of the app and hit "open." What setting did I change? Thanks very much! Please reply here and copy to xapis2@aol.com.

How to draw and move text and image on canvas with java on android?

Hi
I have an university project with canvas but i can not already do it. I have to create a canvas area which has height max 200px top of an activity and i have to able to add text and image to canvas and move them. Then i have to take a bitmap from canvas and save it. I attached a example image of app's activity. Could you please give me an advice or example.

Best and Kind Regards.

canvas.png

LoadURL onReceivedError() not firing

Simple kotlin app under android studio that makes a loadURL to a local address:-

The function often fails, probably due to local net latency with:

Web Page not available
The web page at http://192.168.1.144/apikey/webcam could not be loaded because:
net: ERR_ADDRESS_UNREACHABLE

I have
android:usesCleartextTraffic="true"
<uses-permission android:name="android.permission.INTERNET"/>
in the manifest, and the loadurl often is fine

In order to capture the error and provide a message an
onReceivedError()
action is used.

It never fires

Is the syntax of the onReceivedError correct? It refers to WebView rather than my instance myWebview (which causes a reference error), and I've moved the scope around to no effect.

The Android Studio comment says that the function is never used. A big hint, but I can't see which scope to place it in.

I've copied this from other examples.

I'd really welcome some help please

Robin

Code:
package com.example.lilaccottagebell

import android.app.NotificationChannel
import android.app.NotificationManager
import android.os.Build
import android.os.Bundle
import android.webkit.WebResourceError
import android.webkit.WebResourceRequest
import android.webkit.WebView
import android.webkit.WebViewClient
import android.widget.Button
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            // Create the NotificationChannel
            val name = getString(R.string.channel_name)
            val descriptionText = getString(R.string.channel_description)
            val importance = NotificationManager.IMPORTANCE_DEFAULT
            val CHANNEL_ID = "only_channel"
            val mChannel = NotificationChannel(CHANNEL_ID, name, importance)
            mChannel.description = descriptionText
            // Register the channel with the system; you can't change the importance
            // or other notification behaviors after this
            val notificationManager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager
            notificationManager.createNotificationChannel(mChannel)
        }



        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            // Create channel to show notifications.
            val channelId = getString(R.string.default_notification_channel_id)
            val channelName = getString(R.string.default_notification_channel_name)
            val notificationManager = getSystemService(NotificationManager::class.java)
            notificationManager?.createNotificationChannel(NotificationChannel(channelId,
                    channelName, NotificationManager.IMPORTANCE_HIGH))
        }

        // If a notification message is tapped, any data accompanying the notification
        // message is available in the intent extras. In this sample the launcher
        // intent is fired when the notification is tapped, so any accompanying data would
        // be handled here. If you want a different intent fired, set the click_action
        // field of the notification message to the desired intent. The launcher intent
        // is used when no click_action is specified.
        //
        // Handle possible data accompanying notification message.
        // [START handle_data_extras]

        // [END handle_data_extras]

        val myWebView: WebView = findViewById(R.id.webview)

        /*myWebView.loadUrl("https://amazon.co.uk")*/
        myWebView.webViewClient = WebViewClient()
        WebView.setWebContentsDebuggingEnabled(true)
        /*5 March 2021*/
        myWebView.clearCache(true)






        myWebView.loadUrl("http://192.168.1.144/apikey/webcam")

        val disable_button: Button = findViewById(R.id.disable)
        disable_button.setOnClickListener {
            myWebView.loadUrl("http://192.168.1.144/apikey/disable")

        }

        fun onReceivedError(
                view: WebView,
                request: WebResourceRequest,
                error: WebResourceError
        ) {
            Toast.makeText(this, "Webcam not reachable", Toast.LENGTH_SHORT).show()
        }




    }


}




}


}

GrapheneOS best security question

Hello everybody, i am using Graphene OS and only FOSS apps and i have a question. Recently i see some Foss apps also have "trackers". I want to use a "firewall" like netguard to block internet connection from the apps whoem don't need it + trackercontrol to block the trackers from all the apps and OpenVPN to hide my IP adress. But i can't use these 3 apps at once because the phone recognize them all as an VPN. Does anyone have the solution for this for me?

Filter

Back
Top Bottom