我目前在Android上启动铃声,它播放正常.
然而,当我试图停止铃声时它不会停止或至少不会立即停止,它会一直播放直到它刚播放出来.
以下是我设置铃声的方法:
int rm = audio_service.getRingerMode();
int vs = audio_service.getVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER);
android.os.Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
if ((rm == AudioManager.RINGER_MODE_VIBRATE ||
(rm == AudioManager.RINGER_MODE_NORMAL && vs == AudioManager.VIBRATE_SETTING_ON)))
v.vibrate(vibratePattern,1);
if (audio_service.getStreamVolume(AudioManager.STREAM_RING) > 0) {
oRingtone = RingtoneManager.getRingtone(this, Settings.System.DEFAULT_RINGTONE_URI);
oRingtone.setStreamType(AudioManager.STREAM_RING);
oRingtone.play();
}
Run Code Online (Sandbox Code Playgroud)
以下是我试图阻止它的方法
if (CallDialogActivity.oRingtone != null) {
Log.d("RINGTONE", "Into Ringtone if");
Ringtone ringtone = CallDialogActivity.oRingtone;
oRingtone = null;
ringtone.stop();
}
Run Code Online (Sandbox Code Playgroud)
有没有人遇到过类似的问题或者我的代码中有任何错误?
编辑:
只是要添加我已经添加了日志记录,以便在我调用ringtone.stop()之后看看ringtone.isPlaying()是否返回true或false并且它返回false,但是之前的音调持续播放几秒钟(3 - 5秒)停止
我想知道如何使用foreach迭代具有混合内容的List.请参阅下面的示例代码.
public class GenericsForeach {
class A {
void methodA() {
System.out.println(getClass().getSimpleName() + ": A");
}
}
class B extends A {
void methodB() {
System.out.println(getClass().getSimpleName() + ": B");
}
}
void test() {
List<A> listOfA = new ArrayList<A>();
listOfA.add(new A());
List<B> listOfB = new ArrayList<B>();
listOfB.add(new B());
List<? super A> mixed = new ArrayList<A>();
mixed.addAll(listOfA);
mixed.addAll(listOfB);
Iterator<? super A> it = mixed.iterator();
while (it.hasNext()) {
A item = (A) it.next();
item.methodA();
}
// XXX: this does not work
// …Run Code Online (Sandbox Code Playgroud) class A
{
};
template <typename A, int S>
class B
{
public:
static int a[S];
B()
{
a[0] = 0;
}
};
template<> int B<A, 1>::a[1];
int main()
{
B<A, 1> t;
t;
}
Run Code Online (Sandbox Code Playgroud)
它在GCC 4.1下编译,但没有链接:
static.cpp:(.text._ZN1BI1ALi1EEC1Ev[B<A, 1>::B()]+0x5): undefined reference to `B<A, 1>::a'
Run Code Online (Sandbox Code Playgroud)
如果可能的话,我宁愿保持初始化专用,因为数组包含特定于该类型的一些数据.
为什么这个代码:
var a = new Date();
var b = new Date();
a.setDate(31);
a.setMonth(11);
a.setFullYear(2009);
b.setFullYear(2009);
b.setMonth(11);
b.setDate(31);
Run Code Online (Sandbox Code Playgroud)
2009年12月31日b和2009年12月3日正确输出:-O表示?不在浏览器MyHorribleScrap版本6.6.6中,但在FF 3.6和IE 8.06.6001上
我应该为UPDATE(PUT)和DELETE(例如产品成功更新)设置什么状态代码?
我在git中获取此信息
>git status
# On branch master
# Your branch is ahead of 'origin/master' by 3 commits.
#
nothing to commit (working directory clean)
Run Code Online (Sandbox Code Playgroud)
并且,当我尝试推动时,我得到了这个:
fatal: failed to write object
error: unpack failed: unpacker exited with error code
To ssh:<my repository>
! [remote rejected] master -> master (n/a (unpacker error))
error: failed to push some refs to 'ssh:<my repository>'
Run Code Online (Sandbox Code Playgroud)
我一直在谷歌上搜索一下,(例如这里有一个关于它的stackoverflow问题 - 'git pull origin mybranch'让本地mybranch N在原点之前提交.为什么?)并且一般的建议似乎是做拉然后一个推.但这对我不起作用 - 拉动告诉我,我是最新的.我也试过'git fetch origin'(没什么).我也尝试过:
> git remote …Run Code Online (Sandbox Code Playgroud) 我有一个EditText按钮与父母的底部对齐.
当我在其中输入文本并按下按钮以保存数据时,虚拟键盘不会消失.
任何人都可以指导我如何隐藏键盘吗?
有人可以帮我解决为什么我的列表框是空的吗?
XmlDocument 包含以下 XML:
<Config>
<Tabs>
<Tab Name="Test1" />
<Tab Name="Test2" />
</Tabs>
</Config>
Run Code Online (Sandbox Code Playgroud)
在我的 XAML 文件中,我尝试了以下操作
<Window>
<Grid>
<ListBox DataContext="{Binding {StaticResource Data}, XPath=//Tabs}" ItemsSource="{Binding XPath=Tab/@Name}">
</ListBox>
</Grid>
<Window>
Run Code Online (Sandbox Code Playgroud)
我知道我尚未设置与 name 属性的绑定,但是如果它正常工作,是否应该为每个选项卡节点显示 XmlDocument.XmlNode.ToString() ?
我的 C# 构造函数背后的代码:
InitializeComponent();
this.doc = new XmlDocument();
doc.LoadXml(config.document.OuterXml);
XmlDataProvider provider = (XmlDataProvider)Resources["Data"];
provider.Document = doc;
provider.Refresh();
Run Code Online (Sandbox Code Playgroud)
是config.document.OuterXml包含上述 xml 的有效文档。
我使用 Collections 处理过程代码,但我一直在尝试找出如何直接绑定到 XML。
更新:列表框为空
现在没有绑定错误,但我的列表框为空,我已经仔细检查了我的 XML 文件,甚至执行了 MessageBox.Show(provider.Document.OuterXML) 并可以确认 XmlDocument 确实具有正确的节点。
提前致谢
我想从我的WPF应用程序生成(然后打印或保存)大型XPS文档(> 400页).我们有一些需要写入XPS的大量内存数据.
如果没有得到一个OutOfMemoryException怎么办呢?有没有办法可以把文件写成块?这通常是怎么做的?我不应该首先将XPS用于大文件吗?
这个根本原因OutOfMemoryException似乎是巨大的创造FlowDocument.我正在创建完整FlowDocument,然后将其发送到XPS文档编写器.这是错误的方法吗?
我有这个类似乎在非64位上运行得很好.
using System;
using System.Runtime.InteropServices;
namespace DeleteToRecycleBin
{
/// <summary>
/// Send files directly to the recycle bin.
/// </summary>
public class RecybleBin
{
/// <summary>
/// Possible flags for the SHFileOperation method.
/// </summary>
[Flags]
public enum FileOperationFlags: ushort
{
/// <summary>
/// Do not show a dialog during the process
/// </summary>
FOF_SILENT = 0x0004,
/// <summary>
/// Do not ask the user to confirm selection
/// </summary>
FOF_NOCONFIRMATION = 0x0010,
/// <summary>
/// Delete the file to …Run Code Online (Sandbox Code Playgroud)