1. Download our Official Android App: Forums for Android!

Apps A few how to questions

Discussion in 'Android Development' started by Technologx, Mar 10, 2016.

  1. Technologx

    Technologx Newbie
    Thread Starter
    Rank:
    None
    Points:
    26
    Posts:
    33
    Joined:
    Jun 1, 2015

    How do I go about alerting the user that they have a new notification on my forum? Also how do I allow the user to upload and download files from my forum? I have included the code I have I just have no idea what code I need to add and where I need to add it I'm a complete noob when it comes to doing this.

    Code (Text):
    1.  
    2. package technologx.technologx;
    3.  
    4. /**
    5. * Created by Technologx on 12/22/15
    6. * ©2015 Technologx All Rights Reserved
    7. * http://technologx.fulba.com
    8. */
    9.  
    10. import android.os.Build;
    11. import android.os.Bundle;
    12. import android.annotation.SuppressLint;
    13. import android.app.Activity;
    14. import android.content.Intent;
    15. import android.net.Uri;
    16. import android.view.View;
    17. import android.view.Window;
    18. import android.view.WindowManager;
    19. import android.webkit.CookieSyncManager;
    20. import android.webkit.WebView;
    21. import android.webkit.WebViewClient;
    22.  
    23. @SuppressLint("SetJavaScriptEnabled")
    24. public class MainActivity extends Activity {
    25.  
    26.     private WebView webView;
    27.  
    28.     public void onCreate(Bundle savedInstanceState) {
    29.  
    30.         super.onCreate(savedInstanceState);
    31.  
    32.         // If the Android version is lower than Jellybean, use this call to hide
    33.         // the status bar.
    34.         if (Build.VERSION.SDK_INT < 16) {
    35.             getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
    36.                     WindowManager.LayoutParams.FLAG_FULLSCREEN);
    37.         }
    38.  
    39.         // Adds Progress Bar Support
    40.         this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
    41.         // Makes Progress Bar Visible
    42.         getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);
    43.  
    44.         // Use forum.xml as webview layout
    45.         setContentView(R.layout.activity_main);
    46.  
    47.         webView = (WebView) findViewById(R.id.webView);
    48.         webView.getSettings().setJavaScriptEnabled(true);
    49.  
    50.         // Adds Zoom Control (You may not need this)
    51.         webView.getSettings().setSupportZoom(true);
    52.  
    53.         // Enables Multi-Touch. if supported by ROM
    54.         webView.getSettings().setBuiltInZoomControls(true);
    55.  
    56.         // Change to your own forum url
    57.         webView.loadUrl("http://technologx.96.lt/");
    58.  
    59.         webView.setWebViewClient(new WebViewClient() {
    60.             public boolean shouldOverrideUrlLoading(WebView view, String url) {
    61.                 // Loads only your forum domain and no others!
    62.                 if (url.contains("technologx.96.lt") == true) {
    63.                     view.loadUrl(url);
    64.                     // Adds Progress Bar Support
    65.                     super.onPageStarted(view, url, null);
    66.                     findViewById(R.id.progressbar).setVisibility(View.VISIBLE);
    67.                     // If they are not your domain, use browser instead
    68.                 } else {
    69.                     Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    70.                     startActivity(i);
    71.                 }
    72.                 return true;
    73.             }
    74.  
    75.             @Override
    76.             public void onPageFinished(WebView view, String url) {
    77.                 // Removes Progress Bar
    78.                 findViewById(R.id.progressbar).setVisibility(View.GONE);
    79.                 // Adds Cookies. Yummy!
    80.                 CookieSyncManager.getInstance().sync();
    81.             }
    82.         });
    83.     }
    84.  
    85.  
    86.  
    87.     @Override
    88.     public void onBackPressed() {
    89.         // Enables going back history
    90.         if (webView.copyBackForwardList().getCurrentIndex() > 0) {
    91.             webView.goBack();
    92.         } else {
    93.             // Your exit alert code, or alternatively line below to finish
    94.             // Finishes forum activity
    95.             super.onBackPressed();
    96.         }
    97.     }
    98.  
    99. }
    100.  
     

    Advertisement

Share This Page

Loading...