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

Support I can't import the photos from mobile phone webview APP android

Discussion in 'Android Help' started by Paulino Romeira, Apr 8, 2016.

  1. Paulino Romeira

    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    1
    Joined:
    Apr 8, 2016

    Apr 8, 2016
    1
    0
    5
    Male
    Hello friends, I'm in trouble, I can't import the photos from mobile phone the moment you add the image to the publication of the ad in the webview. I'm trying to make the app but I can't get it to show up the menu where you have the album and take a picture because when you click to add nothing happens! This doing for Webview on android studio. Could someone help me because I'm a beginner.

    This is the code that I use, works perfectly the webview but add the photo at the time of posting does nothing, I don't know what's next, googled and nothing worked! and my theme is responsive!

    Code (Text):
    1. MainActivity.java
    2.  
    3. package com.site.app;
    4.  
    5. import android.app.Activity;
    6. import android.net.Uri;
    7. import android.os.Bundle;
    8. import android.view.Menu;
    9. import android.view.MenuItem;
    10. import android.webkit.WebSettings;
    11. import android.webkit.WebView;
    12. import android.webkit.WebViewClient;
    13.  
    14.  
    15.  
    16.  
    17. public class MainActivity extends Activity {
    18.  
    19.  
    20.     private WebView mWebView;
    21.  
    22.  
    23.     @Override
    24.     protected void onCreate(Bundle savedInstanceState) {
    25.         super.onCreate(savedInstanceState);
    26.         setContentView(R.layout.activity_main);
    27.  
    28.  
    29.         mWebView = (WebView) findViewById(R.id.activity_main_webview);
    30.  
    31.  
    32.         // Force links and redirects to open in the WebView instead of in a browser
    33.         mWebView.setWebViewClient(new WebViewClient());
    34.  
    35.  
    36.         // Enable Javascript
    37.         WebSettings webSettings = mWebView.getSettings();
    38.         webSettings.setJavaScriptEnabled(true);
    39.  
    40.  
    41.         // Use remote resource
    42.         mWebView.loadUrl("http://site.com.br");
    43.  
    44.  
    45.         // Stop local links and redirects from opening in browser instead of WebView
    46.         mWebView.setWebViewClient(new MyAppWebViewClient());
    47.  
    48.  
    49.         // Use local resource
    50.         // mWebView.loadUrl("file:///android_asset/www/index.html");
    51.     }
    52.  
    53.  
    54.     // Prevent the back-button from closing the app
    55.     @Override
    56.     public void onBackPressed() {
    57.         if(mWebView.canGoBack()) {
    58.             mWebView.goBack();
    59.         } else {
    60.             super.onBackPressed();
    61.         }
    62.     }
    63.  
    64.  
    65.     @Override
    66.     public boolean onCreateOptionsMenu(Menu menu) {
    67.         // Inflate the menu; this adds items to the action bar if it is present.
    68.         getMenuInflater().inflate(R.menu.menu_main, menu);
    69.         return true;
    70.  
    71.  
    72.  
    73.  
    74.     }
    75.  
    76.  
    77.     @Override
    78.     public boolean onOptionsItemSelected(MenuItem item) {
    79.         // Handle action bar item clicks here. The action bar will
    80.         // automatically handle clicks on the Home/Up button, so long
    81.         // as you specify a parent activity in AndroidManifest.xml.
    82.         int id = item.getItemId();
    83.  
    84.  
    85.         //noinspection SimplifiableIfStatement
    86.         if (id == R.id.action_settings) {
    87.             return true;
    88.         }
    89.  
    90.  
    91.         return super.onOptionsItemSelected(item);
    92.  
    93.  
    94.         }}
    Code (Text):
    1. activity_main.xml
    2.  
    3. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    4.     xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    5.     android:layout_height="match_parent"
    6.     tools:context=".MainActivity">
    7.  
    8.     <WebView
    9.         android:id="@+id/activity_main_webview"
    10.         android:layout_width="match_parent"
    11.         android:layout_height="match_parent" />
    12.  
    13. </RelativeLayout>
    Code (Text):
    1. AndroidManifest.xml
    2.  
    3. <?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"
    4.     package="com.name.app" >
    5.     <uses-permission android:name="android.permission.INTERNET" />
    6.     <uses-permission android:name="android.permission.CAMERA" />
    7.     <uses-feature android:name="android.hardware.camera" />
    8.     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    9.     <application
    10.         android:allowBackup="true"
    11.         android:icon="@drawable/ic_launcher"
    12.         android:label="@string/app_name"
    13.         android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
    14.         <activity
    15.             android:name="com.name.app.MainActivity"
    16.             android:label="@string/app_name" >
    17.             <intent-filter>
    18.                 <action android:name="android.intent.action.MAIN" />
    19.  
    20.                 <category android:name="android.intent.category.LAUNCHER" />
    21.             </intent-filter>
    22.         </activity>
    23.     </application>
    24. </manifest>
     

    Advertisement

Share This Page

Loading...