Урок 32. Пишем простой браузер
Re: Урок 32. Пишем простой браузер
Приветствую!
Подскажите, пожалуйста, не сталкивался ли кто с такой проблемой, при выборе нашего активити выскакивает ошибка net::ERR_CLEARTEXT_NOT_PERMITTED , при выборее хрома все нормально. uses permission есть.
Подскажите, пожалуйста, не сталкивался ли кто с такой проблемой, при выборе нашего активити выскакивает ошибка net::ERR_CLEARTEXT_NOT_PERMITTED , при выборее хрома все нормально. uses permission есть.
Re: Урок 32. Пишем простой браузер
Помогло данной решение:asfli писал(а):Приветствую!
Подскажите, пожалуйста, не сталкивался ли кто с такой проблемой, при выборе нашего активити выскакивает ошибка net::ERR_CLEARTEXT_NOT_PERMITTED , при выборее хрома все нормально. uses permission есть.
добавить в manifest в тег application следующее:
Код: Выделить всё
android:usesCleartextTraffic="true"
Код: Выделить всё
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.p0321simplebrowser">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true"
>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:label="MyBrowser" android:name="BrowserActivity">
<intent-filter tools:ignore="AppLinkUrlError">
<action android:name="android.intent.action.VIEW"></action>
<data android:scheme="http"></data>
<category android:name="android.intent.category.DEFAULT"></category>
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
Re: Урок 32. Пишем простой браузер
Застопорился на этом уроке. Проблема с манифестом. Уроки прохожу на android studio 3.2.1. Не всё так же работает как в уроках, но раньше мне удавалось заставить работать как надо.
API 22: Android 5.1
Выделяет красным строки:
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<data android:scheme="http"></data>
<category android:name="android.intent.category.DEFAULT"></category>
</intent-filter>
Пишет мол: Activity supporting ACTION_VIEW is not set as BROWSABLE less....(Ctrl+F1)
Ensure the URL is supported by your app, to get installs and traffic to your app from Google Search.
Issue id: AppLinkUrlError.
Подскажите как решить проблему пожалуйста.
MainActivity java
activity_main xml
BrowserActivity
browser.xml
AndroidManifest.xml
API 22: Android 5.1
Выделяет красным строки:
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<data android:scheme="http"></data>
<category android:name="android.intent.category.DEFAULT"></category>
</intent-filter>
Пишет мол: Activity supporting ACTION_VIEW is not set as BROWSABLE less....(Ctrl+F1)
Ensure the URL is supported by your app, to get installs and traffic to your app from Google Search.
Issue id: AppLinkUrlError.
Подскажите как решить проблему пожалуйста.
MainActivity java
Код: Выделить всё
package com.example.p0321simplebrowser;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
(findViewById(R.id.btnWeb)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.ya.ru")));
}
});
}
}
Код: Выделить всё
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<Button
android:id="@+id/btnWeb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="web">
</Button>
</LinearLayout>
Код: Выделить всё
package com.example.p0321simplebrowser;
import android.app.Activity;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class BrowserActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.browser);
WebView webView = (WebView) findViewById(R.id.webView);
webView.setWebViewClient(new WebViewClient());
Uri data = getIntent().getData();
webView.loadUrl(data.toString());
}
}
Код: Выделить всё
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent">
</WebView>
</LinearLayout>
Код: Выделить всё
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.p0321simplebrowser">
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:label="MyBrowser" android:name="BrowserActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<data android:scheme="http"></data>
<category android:name="android.intent.category.DEFAULT"></category>
</intent-filter>
</activity>
</application>
</manifest>
Re: Урок 32. Пишем простой браузер
Мне помогли следующие изменения в манифесте:kefir писал(а):Выделяет красным строки:
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<data android:scheme="http"></data>
<category android:name="android.intent.category.DEFAULT"></category>
</intent-filter>
Пишет мол: Activity supporting ACTION_VIEW is not set as BROWSABLE less....(Ctrl+F1)
Ensure the URL is supported by your app, to get installs and traffic to your app from Google Search.
Issue id: AppLinkUrlError.
Подскажите как решить проблему пожалуйста.
Другой способ решения предлагается здесь https://stackoverflow.com/questions/257 ... iew-action<activity android:name=".BrowserActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<data android:scheme="http"></data>
<category android:name="android.intent.category.BROWSABLE"></category>
</intent-filter>
</activity>
Но я не совсем догнал, что тут происходит, может вы, коллеги, мне объясните
Re: Урок 32. Пишем простой браузер
такой вопрос, решил сделать браузер с небольшими модификациями: прикрутил edittext чтобы вводить адрес, без активити которое создает интент view http, в общем у меня в манифесте
почему не предлагается мое активити когда пытаюсь открыть ссылку с http? (варианты предлагаются но в них нет моего)
Код: Выделить всё
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<data android:scheme="http"/>
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
Re: Урок 32. Пишем простой браузер
проблема в том, что активити запускается с помощью стартактивити только если оно принадлежит к категории дефолт, но добавлением строки не сработало, вот правильно:
Код: Выделить всё
<activity android:name=".MainActivity" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="http"/>
<data android:scheme="https"/>
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
Re: Урок 32. Пишем простой браузер
Ссылка ни в какую не открывается в моем браузере. Только во встроенном. Установлена Android Studio 3.3 система на эмуляторе Android 5.1(API 22). Файл манифеста. Чо не так?
[code][syntax=java]<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.p0321_simplebrowser">
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".BrowserActivity" android:label="MyBrowser">
<intent-filter>
<action android:name="android.intent.action.VIEW."></action>
<data android:scheme="http"></data>
<category android:name="android.intent.category.DEFAULT"></category>
</intent-filter>
</activity>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>[/code][/syntax]
Добавил
[code]<data android:scheme="https"></data>
<category android:name="android.intent.category.BROWSABLE "></category>[/code]
Один хрен всё то же((
Попробовал создать собственный фильтр вместо ACTION_VIEW и прописал его в action в манифесте <activity BrowserActivity. Эмулятор ругнулся и закрыл приложение.
[code][syntax=java]<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.p0321_simplebrowser">
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".BrowserActivity" android:label="MyBrowser">
<intent-filter>
<action android:name="android.intent.action.VIEW."></action>
<data android:scheme="http"></data>
<category android:name="android.intent.category.DEFAULT"></category>
</intent-filter>
</activity>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>[/code][/syntax]
Добавил
[code]<data android:scheme="https"></data>
<category android:name="android.intent.category.BROWSABLE "></category>[/code]
Один хрен всё то же((
Попробовал создать собственный фильтр вместо ACTION_VIEW и прописал его в action в манифесте <activity BrowserActivity. Эмулятор ругнулся и закрыл приложение.
Re: Урок 32. Пишем простой браузер
Настройщик манифеста, как на скрине - в Eclipse. В Android Studio такого нет.mkey писал(а):Добрый день!
Вопрос: где находится этот настройщик манифеста, скрины которого в уроке? Никак не могу найти, может в новой версии студии его нет?
Re: Урок 32. Пишем простой браузер
Если у кого-то на новой Android Studio возникает ошибка с отображением в собственном WebView страницы (это может быть на бОльших API, чем 10, пишет в собственном браузере ошибку net::ERR_CLEARTEXT_NOT_PERMITTED), рекомендуется подправить манифест:
<application
....
android:usesCleartextTraffic="true"
....>
<application
....
android:usesCleartextTraffic="true"
....>
Re: Урок 32. Пишем простой браузер
У меня ошибка в Манифесте пропала после добавления .BROWSABLE (т.е. и .DEFAULT и .BROWSABLE):0xc00000f писал(а): ↑17 янв 2019, 18:44Мне помогли следующие изменения в манифесте:kefir писал(а):Выделяет красным строки:
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<data android:scheme="http"></data>
<category android:name="android.intent.category.DEFAULT"></category>
</intent-filter>
Пишет мол: Activity supporting ACTION_VIEW is not set as BROWSABLE less....(Ctrl+F1)
Ensure the URL is supported by your app, to get installs and traffic to your app from Google Search.
Issue id: AppLinkUrlError.
Подскажите как решить проблему пожалуйста.Другой способ решения предлагается здесь https://stackoverflow.com/questions/257 ... iew-action<activity android:name=".BrowserActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<data android:scheme="http"></data>
<category android:name="android.intent.category.BROWSABLE"></category>
</intent-filter>
</activity>
Но я не совсем догнал, что тут происходит, может вы, коллеги, мне объясните
Код: Выделить всё
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="http" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
Re: Урок 32. Пишем простой браузер
Появилась ошибка на этом уроке. Уроки прохожу на android studio 3.6.3.
Ошибка: unfortunately P032_SimpleBrowser has stopped.
Ошибка появляется после нажатия на кнопку WEB (появляется выбор между нашим Activity и Browse) при выборе нашего Activity с WebView.
При выборе Browser который установлен в системе ошибки на возникает, открывается сайт.
Убрал из Activity элемент WebViev, Activity открылось(без ошибок).
Добавляю WebViev на Activity, в классе не добавляю ни какого кода, ошибка появляется.
Убираю WebViev, ошибок нет.
У прoекта API 19
Проверял на API 21 и 29.
Также на Android Emulator и Genymotion.
Помогите пожалуйста разобратся.
Класс:
Activity
Манифест
Везде одна и та же ошибка(красная строчка из ошибки ссылается на красную строчку в классе):
Ошибка: unfortunately P032_SimpleBrowser has stopped.
Ошибка появляется после нажатия на кнопку WEB (появляется выбор между нашим Activity и Browse) при выборе нашего Activity с WebView.
При выборе Browser который установлен в системе ошибки на возникает, открывается сайт.
Убрал из Activity элемент WebViev, Activity открылось(без ошибок).
Добавляю WebViev на Activity, в классе не добавляю ни какого кода, ошибка появляется.
Убираю WebViev, ошибок нет.
У прoекта API 19
Проверял на API 21 и 29.
Также на Android Emulator и Genymotion.
Помогите пожалуйста разобратся.
Класс:
Код: Выделить всё
package com.pansoft.p032_simplebrowser;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Window;
public class Browse2Activity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_PROGRESS);
[color=#FF0000] setContentView(R.layout.activity_browse2);[/color]
}
}
Код: Выделить всё
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Browse2Activity">
<WebView
android:layout_width="409dp"
android:layout_height="729dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:layout_editor_absoluteY="1dp"
tools:ignore="MissingConstraints" />
</androidx.constraintlayout.widget.ConstraintLayout>
Код: Выделить всё
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.pansoft.p032_simplebrowser">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".Browse2Activity">
<intent-filter tools:ignore="AppLinkUrlError">
<action android:name="android.intent.action.VIEW" />
<data android:scheme="http" />
<data android:scheme="https" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Везде одна и та же ошибка(красная строчка из ошибки ссылается на красную строчку в классе):
Код: Выделить всё
05-02 05:14:38.516 2357-2357/com.pansoft.p032_simplebrowser E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.pansoft.p032_simplebrowser, PID: 2357
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.pansoft.p032_simplebrowser/com.pansoft.p032_simplebrowser.Browse2Activity}: android.view.InflateException: Binary XML file line #9: Error inflating class android.webkit.WebView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class android.webkit.WebView
at android.view.LayoutInflater.createView(LayoutInflater.java:633)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at com.pansoft.p032_simplebrowser.Browse2Activity.onCreate(Browse2Activity.java:14)
at android.app.Activity.performCreate(Activity.java:5937)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
[color=#FF0000]at com.pansoft.p032_simplebrowser.Browse2Activity.onCreate(Browse2Activity.java:14) [/color]
at android.app.Activity.performCreate(Activity.java:5937)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x2040002
at android.content.res.Resources.getText(Resources.java:274)
at android.content.res.Resources.getString(Resources.java:360)
at com.android.org.chromium.content.browser.ContentViewCore.setContainerView(ContentViewCore.java:702)
at com.android.org.chromium.content.browser.ContentViewCore.initialize(ContentViewCore.java:608)
at com.android.org.chromium.android_webview.AwContents.createAndInitializeContentViewCore(AwContents.java:619)
at com.android.org.chromium.android_webview.AwContents.setNewAwContents(AwContents.java:758)
at com.android.org.chromium.android_webview.AwContents.<init>(AwContents.java:608)
at com.android.org.chromium.android_webview.AwContents.<init>(AwContents.java:546)
at com.android.webview.chromium.WebViewChromium.initForReal(WebViewChromium.java:312)
at com.android.webview.chromium.WebViewChromium.access$100(WebViewChromium.java:97)
at com.android.webview.chromium.WebViewChromium$1.run(WebViewChromium.java:264)
at com.android.webview.chromium.WebViewChromium$WebViewChromiumRunQueue.drainQueue(WebViewChromium.java:124)
at com.android.webview.chromium.WebViewChromium$WebViewChromiumRunQueue$1.run(WebViewChromium.java:111)
at com.android.org.chromium.base.ThreadUtils.runOnUiThread(ThreadUtils.java:144)
at com.android.webview.chromium.WebViewChromium$WebViewChromiumRunQueue.addTask(WebViewChromium.java:108)
at com.android.webview.chromium.WebViewChromium.init(WebViewChromium.java:261)
at android.webkit.WebView.<init>(WebView.java
Re: Урок 32. Пишем простой браузер
На новых версиях андроид у людей появились проблемы с манифестом. Я их решил и прилагаю XML манифеста.
Код: Выделить всё
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.blorgen.browser">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.StartAndroid_app">
<activity android:name=".ActivityTwo">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Re: Урок 32. Пишем простой браузер
Можно без этой строки.
Оставить только
Код: Выделить всё
<category android:name="android.intent.category.DEFAULT" />
Код: Выделить всё
<category android:name="android.intent.category.BROWSABLE" />
Re: Урок 32. Пишем простой браузер
У меня тоже забавно выходит:Vitas писал(а): ↑23 янв 2019, 19:38Ссылка ни в какую не открывается в моем браузере. Только во встроенном. Установлена Android Studio 3.3 система на эмуляторе Android 5.1(API 22). Файл манифеста. Чо не так?[/syntax]Код: Выделить всё
[syntax=java]<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.p0321_simplebrowser"> <uses-permission android:name="android.permission.INTERNET"></uses-permission> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".BrowserActivity" android:label="MyBrowser"> <intent-filter> <action android:name="android.intent.action.VIEW."></action> <data android:scheme="http"></data> <category android:name="android.intent.category.DEFAULT"></category> </intent-filter> </activity> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
ДобавилОдин хрен всё то же((Код: Выделить всё
<data android:scheme="https"></data> <category android:name="android.intent.category.BROWSABLE "></category>
Попробовал создать собственный фильтр вместо ACTION_VIEW и прописал его в action в манифесте <activity BrowserActivity. Эмулятор ругнулся и закрыл приложение.
-на AVD kitkat(api 22) работает как надо
-на AVD api 30 как надо
а на реальном девайсе xiaomi (api 29) всегда запускается браузер по умолчанию и выбрать не предлагает
Запустить на своём девайсе получилось только когда прописал свой фильтр Intent.ACTION_SEARCH, вместо ACTION_VIEW. Это какие то заморочки от китайфона?
Re: Урок 32. Пишем простой браузер
Здравствуйте! Всё работает согласно Вашему уроку 32, но есть один маленький вопрос. В Манифесте прописываю android:label="MyBrowser", но название моего браузера не меняется. Подскажите пожалуйста в чем заключается моя проблема со сменой названия (label)?
MainActivity.java
activity_main.xml
BrowserActivity.java
browser.xml
AndroidManifest.xml
MainActivity.java
Код: Выделить всё
package ru.startandroid.p0321simplebrowser;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
(findViewById(R.id.btnWeb)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.ya.ru")));
}
});
}
}
Код: Выделить всё
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnWeb"
android:text="web">
</Button>
</LinearLayout>
Код: Выделить всё
package ru.startandroid.p0321simplebrowser;
import androidx.appcompat.app.AppCompatActivity;
import android.net.Uri;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class BrowserActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.browser);
WebView webView = (WebView) findViewById(R.id.webView);
webView.setWebViewClient(new WebViewClient());
Uri data = getIntent().getData();
webView.loadUrl(data.toString());
}
}
Код: Выделить всё
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/webView">
</WebView>
</LinearLayout>
Код: Выделить всё
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ru.startandroid.p0321simplebrowser">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AndroidLessons">
<activity android:label="MyBrowser" android:name="BrowserActivity">
<intent-filter>
<action android:name="android.intent.action_VIEW" />
<data android:scheme="http"></data>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
- Вложения
-
- Screenshot_1.png (105.59 КБ) 5348 просмотров