我想我已经尝试了我在互联网上找到的所有解决方案,但没有人工作 - 没有力量关闭,但桌面上没有任何内容.
现在,我有这个:
private void createShortcutOnDesktop(Application app) {
Intent shortcutIntent = new Intent();
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, app.getIntentShortcut());
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, app.getName());
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(context, R.drawable.home_button));
shortcutIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
this.sendBroadcast(shortcutIntent);
finish();
}
Run Code Online (Sandbox Code Playgroud)
的app.getIntentShortcut():
public Intent getIntentShortcut() {
Intent i = new Intent();
i.setClassName(packageName, name);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
return i;
}
Run Code Online (Sandbox Code Playgroud)
并在AndroidManifest.xml文件中:
<permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
Run Code Online (Sandbox Code Playgroud)
我错过了什么?谢谢.
我知道不建议这样做,但我需要它,因为页面内有一个 iframe,它具有实际内容,并且我希望当用户点击刷新按钮时,iframe 不会重新加载整个页面。
我知道我必须打电话onunload/onbeforeunload事件,但我不想问我是否要离开窗口,只是不要。
那可能吗?我已经处理了 F5 键,但我也喜欢阻止按钮刷新。
我正在尝试使用OAuth 2.0访问Google的Documents List API 3.0,但我遇到了401错误的麻烦.
用户接受后,我的代码如下:
GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters();
oauthParameters.setOAuthConsumerKey(CLIENT_ID);
oauthParameters.setOAuthConsumerSecret(CLIENT_SECRET);
oauthParameters.setOAuthToken(token);
oauthParameters.setOAuthTokenSecret(tokenSecret);
oauthParameters.setScope("https://docs.google.com/feeds/");
service = new DocsService("myapp");
service.setOAuthCredentials(oauthParameters, new OAuthHmacSha1Signer());
DocumentListFeed feed = service.getFeed(new URL("https://docs.google.com/feeds/default/private/full/?v=3"), DocumentListFeed.class);
Run Code Online (Sandbox Code Playgroud)
然后,在最后一行-getFeed() - 抛出异常:
com.google.gdata.util.AuthenticationException: Token invalid - Invalid token: Request token used when not allowed.
<HTML>
<HEAD>
<TITLE>Token invalid - Invalid token: Request token used when not allowed.</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Token invalid - Invalid token: Request token used when not allowed.</H1>
<H2>Error 401</H2>
</BODY>
</HTML>
Run Code Online (Sandbox Code Playgroud)
这是怎么回事?在一个静态主测试类上工作就像一个魅力,但当我在服务器上运行它时,这条线不再起作用了.任何的想法?
解决了
需要使用GoogleOAuthHelper以这种方式检索访问令牌,而不是直接使用GoogleOAuthParameters:
String …Run Code Online (Sandbox Code Playgroud)