Redirection to a WebPage without Connectivity Check (RWPC)

ECn Categories > Redirection to a Different Application without Connectivity Check (RDAC) > Redirection to a WebPage without Connectivity Check (RWPC)

The app redirects the user to a web page (using a browser) and it does not works because it has not internet connection.

Amount of Issues App List
45 (A1) QKSMS, (A2) Wire, (A4) Galaxy Zoo, (A6) PressureNet, (A7) AnntenaPod, (A8) iFixit, (A11) Mozilla Stumbler, (A12) XOWA, (A13) Journal with Narrate, (A14) Wikimedia Commons, (A15) WordPress, (A16) GnuCash, (A17) My expenses, (A18) FBReader, (A19) K-9 Mail, (A20) MAPS.ME, (A21) Omni Notes, (A22) Hubble Gallery, (A23) Prey, (A24) Forecastie, (A30) Earth viewer, (A32) Cannonbal, (A33) OpenBikeSharing, (A34) c:geo, (A35) PAT Track, (A37) Runner Up, (A38) Wake You In Music, (A39) Habitica, (A41) Glucosio, (A42) Signal Private Messenger, (A43) Tasks: Astrid To-Do List Clone, (A45) Kontalk Messenger, (A47) RedReader

Examples

QKSMS

Category: Communication
v 2.7.3
Scenario: To make a donation with PayPal through the mobile app without internet connection
This video shows an example of a redirection to a web page without connectivity check. At 5th second the user selects in the upper-right corner menu the option donate. After that a new dialog is shown with some predefined amounts the user may donate, when the user selects one the app redirect the user to a web page, but due to connectionless state the web page is not load and the browser in charge of displaying the information shows an error message.

The following code snippets show the classes and files that are involved in the generation of the previuos issue.

In order to see how this error is generated, we need to review all the flow event. First, we have the layout that is displayed when the “Donate” option is selected from the menu, the following snippet shows the code related to the “Donate any amount” option with id “donate_paypal” selected by the user.

src/main/res/layout/dialog_donate.xml

    <LinearLayout
101.    android:id="@+id/donate_paypal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:padding="8dp">

        <com.moez.QKSMS.ui.view.QKTextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
110.        android:text="@string/donate_paypal_button"
            app:type="primary" />

        <com.moez.QKSMS.ui.view.QKTextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/donate_paypal_button_summary"
            app:type="secondary" />

    </LinearLayout>

Once the user has selected the current option, the event flow lands in the “DonationManager” class that manages the donation process. First, at line 200 the previous layout snippet get assigned the event that will be triggered when the user clicks on it.

src/main/java/com/moez/QKSMS/common/DonationManager.java

      View view = mContext.getLayoutInflater().inflate(R.layout.dialog_donate, null);
      view.findViewById(R.id.donate_1).setOnClickListener(clickListener);
      view.findViewById(R.id.donate_5).setOnClickListener(clickListener);
      view.findViewById(R.id.donate_10).setOnClickListener(clickListener);
200.  view.findViewById(R.id.donate_paypal).setOnClickListener(clickListener);

Second, at line 190 the method used before is defined for the option selected for the user. It listens to a click event on the layout defined on the previous file and calls “donatePaypal” method.

src/main/java/com/moez/QKSMS/common/DonationManager.java

    public void showDonateDialog() {

        View.OnClickListener clickListener = view -> {
            switch (view.getId()) {
                case R.id.donate_1:
                    onDonateButtonClicked(SKU_DONATE_1);
                    break;
                case R.id.donate_5:
                    onDonateButtonClicked(SKU_DONATE_5);
                    break;
                case R.id.donate_10:
                    onDonateButtonClicked(SKU_DONATE_10);
                    break;
190.            case R.id.donate_paypal:
191.                donatePaypal();
                    break;
            }
        };

Third, at line 217 the “donatePaypal” method creates an implicit intent for the browser to solved it, but in any moment a connection state validation is made, then when the intent is solve the browser displays an error web page.

src/main/java/com/moez/QKSMS/common/DonationManager.java

    public void donatePaypal() {
217.    Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://bit.ly/QKSMSDonation"));
        mContext.startActivity(browserIntent);
    }