小编A-S*_*ani的帖子

在Android中同时播放多个声音

我无法使用以下代码同时播放多个声音/哔声.在我的onclicklistener我已经加入:

public void onClick(View v) { 
     mSoundManager.playSound(1); 
     mSoundManager.playSound(2); 
} 
Run Code Online (Sandbox Code Playgroud)

但是这一次只播放一个声音,声音索引为1,声音索引为2.

每当有onClick()事件时,如何使用此代码同时播放至少2个声音?

public class SoundManager {

private  SoundPool mSoundPool; 
private  HashMap<Integer, Integer> mSoundPoolMap; 
private  AudioManager  mAudioManager;
private  Context mContext;


public SoundManager()
{

}

public void initSounds(Context theContext) { 
     mContext = theContext;
     mSoundPool = new SoundPool(4, AudioManager.STREAM_MUSIC, 0); 
     mSoundPoolMap = new HashMap<Integer, Integer>(); 
     mAudioManager = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);         
} 

public void addSound(int Index,int SoundID)
{
    mSoundPoolMap.put(1, mSoundPool.load(mContext, SoundID, 1));
}

public void playSound(int index) { 

     int streamVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC); 
     mSoundPool.play(mSoundPoolMap.get(index), streamVolume, streamVolume, …
Run Code Online (Sandbox Code Playgroud)

audio android soundpool

5
推荐指数
1
解决办法
1万
查看次数

5
推荐指数
3
解决办法
4556
查看次数

Android:canvas.drawoval()+旋转

我想绘制一个椭圆形,但我希望能够旋转它.我知道我可以使用canvas.drawOval(...)canvas.rotate(...).但是,我想旋转我的椭圆而不是整个画布; 也就是说,我想先将椭圆旋转到画布上.我在绘制之前通过操纵坐标成功地旋转了一个矩形,但这种方法对我来说不适用于椭圆形.

android canvas rotation

5
推荐指数
1
解决办法
1451
查看次数

C#HttpClient FormUrlEncodedContent编码(VS 2012)

我正在使用HttpClient.我发布了web表单参数.其中一个值(不是名字)是外国瑞典人字符ö,#246; öASCII:Latin Small Letter O Umlaut

手动,IE,Firefox和Chrome都将此角色转换为S%F6k,一切正常.然而,VS 2012 C#版本将其(通过FormUrlEncodedContent(dict))转换为%C3%B6

有没有办法告诉VS 2012将其转换为友好的S%F6k(仍然使用HttpClient)?

我附上了大部分代码,可能会帮助其他人(cookie,代理等......)

// Create Handler
var handler = new HttpClientHandler();

// Cookies
var cc = new CookieContainer();
handler.CookieContainer = cc;

// Proxy - for fiddler
WebProxy proxy = new WebProxy();
proxy.Address = new Uri("http://localhost:8888");
handler.Proxy = proxy;

// Create the client
var client = new HttpClient(handler);

var request4 = new HttpRequestMessage();

client.DefaultRequestHeaders.Clear();
client.DefaultRequestHeaders.Add("Accept", "text/html, application/xhtml+xml, */*");
client.DefaultRequestHeaders.Add("Accept-Encoding", "gzip, deflate");
client.DefaultRequestHeaders.Add("Accept-Language", "en-US,en;q=0.8,sv-SE;q=0.5,sv;q=0.3");
client.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; …
Run Code Online (Sandbox Code Playgroud)

c# visual-studio

5
推荐指数
1
解决办法
2万
查看次数

Android备份/恢复示例不起作用?

我遇到了同样的问题 - 正如谷歌开发者小组中所发现的那样.我引用Chris Grebeldinger(原作者)的非常详细的解释.

"在文档中:http: //developer.android.com/guide/topics/data/backup.html#Testing

它建议通过以下方式测试应用程序的备份/恢复:

  1. 安装你的应用程序
  2. 确保启用备份/恢复
  3. 更改一些数据并调用dataChanged()
  4. 强制bmgr运行备份传递
  5. 卸载应用程序
  6. 重新安装应用程序并检查您的数据是否已恢复

一切似乎都很好,直到第4步,当我在日志中看到这个:

V/BackupManagerService(306):removePackageParticipantsLocked:uid = 10078#1 V/BackupManagerService(306):删除com.example.app的备份知识

然后是第5步:

V/BackupManagerService(306):restoreAtInstall pkg = com.example.app token = 21 V/BackupManagerService(306):没有恢复集 - 跳过恢复

因此,当卸载应用程序时,显然备份的数据会被破坏,这意味着官方测试工作流程可能无法正常工作?测试这个的最佳方法是什么?"

有没有人设法运行并正确测试此样本?

backup android

5
推荐指数
1
解决办法
3523
查看次数

在xamarin中,如何获取Android设备的当前语言?

我怎样才能在Xamarin(Andriod)中获得该设备的当前语言?

通过context.Resources.Configuration.Locale.Language获得语言

android xamarin

5
推荐指数
2
解决办法
8624
查看次数

使用c#使下载可恢复

我正在使用此方法(WebClientClass)从Internet下载文件:

private Task DownloadUpdate(string url, string fileName)
{
       var wc = new WebClient();
       return wc.DownloadFileTaskAsync(new Uri(url), @"c:\download" + fileName);
}
Run Code Online (Sandbox Code Playgroud)

如何使用上述代码使下载恢复

c# asynchronous webclient-download

5
推荐指数
1
解决办法
4664
查看次数

knockoutjs radio integer databind for check not working

检查JSFiddle

<div data-bind="foreach: ids" class="">
    <label>                      
        <input type="radio"  name="someid" data-bind="value: value, checked: $root.selectedid" />
        <span data-bind="text: text"></span>
    </label>
</div>
<br/>
<input type="button" data-bind="click: test1" value="Test1"/>
<input type="button" data-bind="click: test2" value="Test2"/>
<input type="button" data-bind="click: test3" value="Test3"/>
Run Code Online (Sandbox Code Playgroud)

function radiodata(text,value){this.text = text; this.value = value; }

var viewModel = function(){
    var self = this;
    self.selectedid = ko.observable();

    self.ids = ko.observableArray([
        new radiodata('one',1),
        new radiodata('two',2),
        new radiodata('three',3)
         ]);
    self.test1 = function(){
      self.selectedid(2);//this doesnot work
    };
     self.test2 = function(){
      self.selectedid('2');//this works
    };
     self.test3 = …
Run Code Online (Sandbox Code Playgroud)

data-binding knockout.js

5
推荐指数
1
解决办法
2424
查看次数

通过 aws ses 在 node.js 中发送带有附件的邮件

有没有人有一些关于如何node.js使用 aws ses发送带有附件的电子邮件的示例?

email email-attachments amazon-web-services node.js amazon-ses

5
推荐指数
2
解决办法
5681
查看次数

启用实体框架自动迁移不起作用

我有这个数据库配置

public class AppDbContext : DbContext 
    {

         public AppDbContext(string connectionStringOrName)
            : base(connectionStringOrName)
        {
            Database.SetInitializer(new AppDbInitializer());
        }

         public AppDbContext()
             : this("name=AppDbContext")
        {

        }

         public DbSet<User> Users { get; set; }
         public DbSet<Log> Logs { get; set; }
    }
Run Code Online (Sandbox Code Playgroud)

我有这个迁移配置

public class AppDbInitializer : MigrateDatabaseToLatestVersion<AppDbContext,AppDbMigrationConfiguration>
{
}


  public class AppDbMigrationConfiguration : DbMigrationsConfiguration<AppDbContext>
    { 
        public AppDbMigrationConfiguration()
        {
            AutomaticMigrationsEnabled = true;
            AutomaticMigrationDataLossAllowed = true;
        }

        protected override void Seed(AppDbContext context)
        {
            if (context.Users.Any()) return;

            AddAdmin(context, "Admin", "admin@test.com");
        }
   }
Run Code Online (Sandbox Code Playgroud)

我向 Log 实体添加了另一个字段。

实体框架可以自动检测并应用更改吗?

c# entity-framework automatic-migration entity-framework-migrations

5
推荐指数
1
解决办法
9819
查看次数