- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我开发了一个通知应用程序,单击通知后需要打开一个 Activity 。但是当我单击模拟器右上角的通知图标时,什么也没有发生。它应该打开NotificationView Activity 。在logcat数据中,我发现了一个警告 W/InputMethodManagerService(1214): 窗口已经聚焦,忽略焦点增益:com.android.internal.view.IInputMethodClient$Stub$Proxy@b4e4dbd8 attribute=null, token = android. os.BinderProxy@b4a95d50
文件如下...MainActivity.java
package com.example.notification1;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
public class MainActivity extends ActionBarActivity {
Button b1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
b1=(Button)findViewById(R.id.button);
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Notify("You've received new message","ghfghfghfghf hfghfdgh f fgj f gjdf fghfg");
}
});
}
private void Notify(String notificationTitle, String notificationMessage){
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
@SuppressWarnings("deprecation")
Notification notification = new Notification(R.drawable.ic_launcher,"New Message", System.currentTimeMillis());
Intent notificationIntent = new Intent(this,NotificationView.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,notificationIntent, 0);
notification.setLatestEventInfo(MainActivity.this, notificationTitle,notificationMessage, pendingIntent);
int notificationId = (int) (System.currentTimeMillis()/1000);
notificationManager.notify(notificationId, notification);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@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.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
NotificationView.java
package com.example.notification1;
import android.os.Bundle;
import android.app.Activity;
public class NotificationView extends Activity{
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.notification);
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.notification1"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".NotificationView"
android:label="@string/app_name" />
</application>
</manifest>
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="MainActivity">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Notification Example"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:textSize="30dp" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hello world "
android:textColor="#ff87ff09"
android:textSize="30dp"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="48dp" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageButton"
android:src="@drawable/ic_launcher"
android:layout_below="@+id/textView2"
android:layout_centerHorizontal="true"
android:layout_marginTop="42dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Notification"
android:id="@+id/button"
android:layout_marginTop="62dp"
android:layout_below="@+id/imageButton"
android:layout_centerHorizontal="true" />
</RelativeLayout>
通知.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:layout_width="fill_parent"
android:layout_height="400dp"
android:text="Hi, Your Detailed notification view goes here...." />
</LinearLayout>
最佳答案
尝试将 FLAG_ACTIVITY_REORDER_TO_FRONT
或 FLAG_ACTIVITY_CLEAR_TOP
和 FLAG_ACTIVITY_SINGLE_TOP
的组合添加到 Intent
还添加任务 stach 构建器
Intent resultIntent = new Intent(this, ResultActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addParentStack(ResultActivity.class);
// Adds the Intent that starts the Activity to the top of the stack
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(resultPendingIntent);
希望这对你有帮助
关于java - 窗口已经聚焦,忽略我的通知应用程序中 : com. android.internal.view 的焦点增益,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33804933/
我有一个登录框,当 出现时,它会上下滑动/切换。单击链接。 这是一个尺寸约为 150 像素 x 100 像素的 DIV。 当有人点击此 DIV 外部时,我希望 DIV 滑动备份。我一直在玩 focu
jQuery 会阻止这种类型的行为吗? $("input").focusout(function() { $(this).focus(); }); 最佳答案 这是如何完成的(跨浏览器工作):
我想将聚焦和未聚焦窗口的 Alpha 设置为 90% 和 70%,而不是使用边框。这将适用于所有窗口,除了那些匹配某些标准(例如 className =“Gimp”)的窗口。我如何在我的 xmonad
我的布局中有一个 Recyclerview 和一个 EditText。 当我在 EditText 外部单击(即单击 Recyclerview)时,我希望 Recyclerview 获得焦点,而 Edi
我正在开发一个使用旧版 jQuery 1.3.2 的元素。我需要在 focus 上 blur 输入值并在 focusout 上返回它(如果没有改变)(不能使用 placeholder在这里)。 这就是
我有一个带有几个 TextViews 的自定义抽屉导航。这是布局: 问题是,如果我没有为 TextView
是否有一种简单的方法可以使我的应用程序的 float 工具选项板永久处于事件状态?它们都与打开的文档相关,因此没有理由让它们在任何时间点处于不活动状态。 最佳答案 使用 NSPanel 作为实用程序窗
尽管阅读了我可以在developer.android.com和stackoverflow上获得的所有内容,但是我确实认为应该可以实现,但是我仍然不知道该怎么做。 我正在尝试使用OpenGL ES 2.
我想在页面加载时聚焦一个元素( slider /轮播),以允许使用箭头键立即控制 slider 。 JQuery 的 .focus() 可以工作,但会自动将元素滚动到 View 中。这是有限视口(vi
我正在尝试让我的代码针对 Mozzila 中 14 年未修复的错误,该错误无法重新关注输入。我在多个地方发现(google mozilla focus not working 中的前 20 个结果中的
我有 ViewController,我想通过焦点引擎检索控制权。首先,我尝试通过要求自己查看来启动。 if settingsFilterSegment.isFocused {} 但我变得错误了,所以我
我想以编程方式将焦点设置在连续一列的表格中 NSTableCellView 中的两个编辑字段之一上,以便用户可以立即编辑该字段。在我的示例中,我可以选择该行(按下按钮后),但我找不到将焦点设置在特殊字
我创建了一个小的 Tab-Layout。 现在我如何根据 TabWidget 的状态(聚焦、按下...)指定它的颜色 我构建了一个新的 .xml,但我不知道如何将它设置到我的选项卡:
我有一个带有 JTree 的 JDialog,其中包括 DefaultMutableTreeNode 及其子节点。我希望在显示 JDialog 时聚焦树的节点之一。只需使用 tree.requestF
当我单击 EditText 时,会出现软键盘。我不希望在单击 EditText 时出现键盘,但是,我想获得 EditText 的力量。我想在没有键盘的情况下编辑它。 editText.setOnCli
在下图中,您可以看到“>”符号周围有一个虚线的“内部”边框,表示该按钮已获得焦点。 (我还在按钮周围添加了一个蓝色边框) 在我构建这些按钮的代码中,我正在做: setTimeout(function(
我在 css 上相当“新手”,并试图在主 div 聚焦时更改 FontAwesome 图标的颜色。我尝试了几种方法,尝试使用 div 的 id 或 class 在 focus 上更改它的颜色,但都没有
我如何判断焦点事件是由于输入按下=表单提交而发生还是仅仅因为单击而发生?进入控制台的事件数据是“focusout”类型,没有相关信息 $(".clientrow[clientid="+clientid
我有个小问题。目前,我正在使用 WordPress 开发一个带有 Flash 游戏的简单网页。 例如考虑这个页面:http://ggames.eu/2015/11/25/prince-of-persi
A 有一个 ListBox,需要在特定情况下聚焦特定项目(例如,显示搜索结果时)。这是通过附加属性使用以下函数完成的: public static void OnElementIndexPropert
我是一名优秀的程序员,十分优秀!