package com.yoalfaaz.yoalfaaz;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.ShareActionProvider;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.support.v4.view.MenuItemCompat;
public class MainActivity extends AppCompatActivity {
private WebView YoWeb;
private ShareActionProvider mShareActionProvider;
SwipeRefreshLayout swipe;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
YoWeb = (WebView)findViewById(R.id.webview); // Move your declaration up here
swipe = (SwipeRefreshLayout) findViewById(R.id.swiperefresh);
swipe.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
LoadWeb(YoWeb.getUrl()); // Pass in the current url to refresh
}
});
LoadWeb("https://www.yoalfaaz.com"); // load the home page only once
}
public void LoadWeb(String url) // Pass in URL you want to load
{
WebSettings webSettings = YoWeb.getSettings();
webSettings.setJavaScriptEnabled(true);
YoWeb.loadUrl(url); // Load the URL passed into the method
swipe.setRefreshing(true);
YoWeb.setWebViewClient(new WebViewClient() {
//onPageFinished Method
public void onPageFinished(WebView view, String url) {
//Hide the SwipeRefreshLayout
swipe.setRefreshing(false);
}
});
}
@Override
public void onBackPressed() {
if (YoWeb.canGoBack()) {
YoWeb.goBack();
} else {
super.onBackPressed();
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
switch (item.getItemId()) {
case R.id.action_settings:
return true;
default:
return super.onOptionsItemSelected(item);
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate menu resource file.
getMenuInflater().inflate(R.menu.menu_main, menu);
// Locate MenuItem with ShareActionProvider
MenuItem item = menu.findItem(R.id.menu_item_share);
// Fetch and store ShareActionProvider
mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);
// Return true to display menu
return true;
}
// Call to update the share intent
private void setShareIntent(Intent shareIntent) {
if (mShareActionProvider != null) {
mShareActionProvider.setShareIntent(shareIntent);
}
}
//private Intent setShareIntent() {
// Intent shareIntent = new Intent();
// shareIntent.setAction(Intent.ACTION_SEND);
// shareIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
// shareIntent.setType("text/plain");
// startActivity(shareIntent);
// return shareIntent;
//}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yoalfaaz.yoalfaaz">
<uses-permission android:name="android.permission.INTERNET" />
<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"
android:configChanges="orientation|keyboardHidden"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter >
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:host="www.yoalfaaz.com" android:scheme="https"/>
</intent-filter>
</activity>
<activity android:name=".SplashScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
如何让它像与大多数其他应用程序一样工作?比如,如果我们在WhatsApp中点击一个YouTube链接,那么特定的视频将在YouTube应用程序中打开,而不是在YouTube主页中打开。
LoadWeb("https://www.yoalfaaz.com"); // load the home page only once
使用getintent().getdata().tostring()
获取从其他应用程序单击的URL(作为字符串
)并使用此URL加载web视图,而不是硬编码URL。
如果没有从getdata()
收到URL,请检查null
并加载默认URL。
希望这能有所帮助。
LoadWeb("https://www.yoalfaaz.com"); // load the home page only once
String url = "https://www.yoalfaaz.com";
if(null != getIntent().getData()){
url = getIntent().getData().toString();
}
LoadWeb(url);
我的应用程序使用的是谷歌应用程序邀请框架(firebase之前的版本),电子邮件邀请中的链接工作正常,用户点击链接,应用程序打开并检索到深度链接。然而,当用户通过短信发送时,嵌入链接反而打开play store?用户点击打开应用但没有链接? 就好像短信链接看不到用户设备上的应用程序一样,你有什么想法吗? 有点像我错过了短信打开应用程序的权限? 用于链接检索的清单摘录: 和我的邀请建造者代码: 更新
如果应用程序已由Deep link打开,则Deep link不起作用。 但是,如果我不是通过触发深度链接来打开应用程序,比如单击应用程序图标来打开应用程序。之后触发deeplink将一直有效。 详情如下: 所以我在AndroidManifest中设置了这样的活动,即LaunchActivity。 在LaunchActive中,我将打印一个日志,以表明它已经在那里。 我用了 测试深层链接。 应用程序
我已经在我的设备上本地开发了一个android应用程序(应用程序还没有在android play商店上)。我有以下逻辑在主体活动中获得深度链接。 我用Firebase控制台建立了一些动态链接,并在手机浏览器中打开。但它不是打开我的应用程序并到达行字符串deepLink=appinvitereferral.getdeeplink(intent); 我在清单文件中有意图过滤器。
我想使用Electron(macOS)打开应用程序并通过深度链接传递参数。 “electron deep linking mac win”项目位于GitHub上。 编辑了,遵循“electron builder”快速安装指南生成mac安装程序: 编辑,添加代码以注册url方案协议,侦听“打开url”事件并记录参数: 走向生活的步骤:-) 运行安装程序()后,我尝试打开电子-深-链接-os应用程序与
我遵循了Firebase动态链接文档中的所有步骤: 已将团队Id添加到firebase控制台 已添加自定义域 启用的关联域 已添加到信息URL方案 然而,当我点击动态链接时,它总是重定向到AppStore,而不是应用程序。我已经尝试了不间断的应用程序,重新启动手机和重新安装。如何让这个深度链接发挥作用? 附注:我的应用程序还没有发布到AppStore。
我在我的应用程序中启用了应用链接。它工作正常。但是在我的应用程序中,有一些情况下我无法处理传入的网址。在这种情况下,我想将该网址重定向到设备中的默认浏览器。 目前,我尝试使用intent打开带有url的浏览器,但它再次重定向到我的应用程序本身。应用程序链接的格式如下- 所以根据params,我想要么在应用程序本身中处理应用程序链接,要么将其重定向到默认浏览器。下面是我试图用上面的网址打开浏览器的代
从这篇文章中,我能够创建一个功能,将用户从一个链接重定向到android或ios。但是,在检测到Android时,我想打开显示我的应用程序的游戏商店。我在重定向时尝试了以下链接: 但它会在浏览器中打开play store。我想打开play store应用程序,我假设我的应用程序用户将使用play store应用程序,所以我不想检查play store应用程序是否已安装。我也尝试了如下的市场链接 但
跟着https://developer.android.com/training/app-links/verify-site-associations.html并设置应用程序链接以打开来自谷歌的应用程序。根据这个链接 assetlinks.json文件从未正确部署到。NET应用程序。然而,当我删除assetlinks.json应用程序仍然对应用程序开放。甚至需要资产链接文件吗?还是这只是应用程序的