我试图在android中调用一个URL
HttpClient mClient= new DefaultHttpClient()
HttpGet get = new HttpGet("www.google.com ");
mClient.execute(get);
HttpResponse res = mClient.execute(get);
Run Code Online (Sandbox Code Playgroud)
但是,我没有得到任何回应.如何在Android中调用URL?
我正在一个项目中工作,并且被困在登录/注册页面的实施中。当我尝试执行代码时,它给了我错误Cleartext HTTP traffic to 192.168.1.130 not permitted。我检查了ipconfig,那是我的IPv4,所以我添加了192.168.1.130,但我也检查了127.0.0.1,但是那个也不起作用。
我尝试实现<domain includeSubdomains="true">192.168.1.130</domain>但是不起作用(实现android:usesCleartextTraffic="true"也不起作用)。
我在后端使用XAMPP,如果我运行php代码,一切正常,因此没有问题。问题出在Android Studio(我正在使用Kotlin)中。
对于仿真器,我正在使用Genymotion仿真器(它使用VirtualBox)。
这是采用的按钮的代码url。我检查了所有内容,但仍未实现。
login.setOnClickListener {
var url = "http://192.168.1.130/php/login.php?mobile=" + login_user.text.toString() +
"&password=" + login_password.text.toString()
Run Code Online (Sandbox Code Playgroud) 我正在使用Flutter Sound 插件从 Android 上的 URL 播放音乐。这在 Android 8 上没有任何问题,但更新到 Android 9 后,来自 URL 的音乐不再播放。我为插件打开了一个问题,但这似乎是 Android 9 本身的一些重大变化。
Android 9 中是否有任何更改会导致此问题?
我在android 9 changes上找不到任何明显的东西。
这是日志输出:
I/MediaPlayer(26707): Need to enable context aware info
V/MediaPlayer-JNI(26707): native_setup
I/flutter (26707): error: Exception: Player already stopped.
V/MediaPlayerNative(26707): constructor
V/MediaPlayerNative(26707): setListener
V/MediaHTTPService(26707): MediaHTTPService(android.media.MediaHTTPService@b2558b2): Cookies: null
V/MediaPlayerNative(26707): setVideoSurfaceTexture
V/MediaPlayerNative(26707): prepare
V/MediaHTTPService(26707): makeHTTPConnection: CookieManager created: java.net.CookieManager@b993003
V/MediaHTTPService(26707): makeHTTPConnection(android.media.MediaHTTPService@b2558b2): cookieHandler: java.net.CookieManager@b993003 Cookies: null
D/MediaHTTPConnection(26707): setReadTimeOut = 15000ms
D/NetworkSecurityConfig(26707): Using Network Security Config from …Run Code Online (Sandbox Code Playgroud) android android-mediaplayer dart flutter flutter-dependencies
摘要/背景
我连续 8 个小时试图解决一个似乎没有任何可行解决方案的问题:突然间,我的 Ionic Cordova 项目在连接互联网时开始出现问题。
我试图安装 Firebase 并设置 FCM,这让我遇到了这个问题。我最终回滚到我拥有的稳定版本,该版本工作完美并且没有给我带来任何问题。但问题仍然存在。就目前而言,在这个问题得到解决之前,我的应用程序完全死了而且毫无用处。
解释问题
fetch('http://www.google.com')返回状态 404。ionic serve,可以正确访问我的服务器资源并正常执行网络请求。到目前为止我已经尝试过的:
<meta>接受所有请求的标签,正如另一个线程中建议的那样。<allow-navigation href="*" />到config.xml文件中。系统和设置:
使用以下命令生成的转储ionic info:
Ionic:
Ionic CLI : 5.2.5 (C:\Users\zerok\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : @ionic/angular 4.0.0
@angular-devkit/build-angular : 0.12.4
@angular-devkit/schematics : …Run Code Online (Sandbox Code Playgroud)