小编use*_*434的帖子

如何在android中设置自定义声音通知

我将mp3(kalimba.mp3)文件复制到raw文件夹中的res文件夹中.但是当触发通知时,它会产生默认声音.

这是我发出通知的方式:

protected void GenerateNotify() {

    NotificationManager myNotificationManager=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);  
    Notification notification=new Notification(android.R.drawable.ic_btn_speak_now,"hi",100);
    Intent intent=new Intent(getApplicationContext(),as.class);
    PendingIntent contentintent=PendingIntent.getBroadcast(getApplicationContext(),0, intent, 0);
    notification.setLatestEventInfo(getApplicationContext(), "Hi","date", contentintent);
    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    notification.sound = Uri.parse("android.resource://com.example.serviceproject/" + R.raw.kalimba);
    myNotificationManager.notify(NOTIFICATION_ID,notification);
}
Run Code Online (Sandbox Code Playgroud)

android

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

如何在android布局中添加unityplayer作为子视图?

我想在android布局中添加unityview作为子视图.我在android xml文件中创建相对布局,并将unityview添加到relativelayout.但是统一视图在相对布局的左下方显示为小图像.

黑色部分是我的相对布局,但统一视图不占用进入相对布局.

代码如下:

  public class MainActivity extends UnityPlayerActivity {

            public static Context mContext;
            private Handler handler=new Handler();
            private UnityPlayer m_UnityPlayer;

            @Override
                protected void onCreate(Bundle bundle) {
                    super.onCreate(bundle);


                            mContext = this;
                            m_UnityPlayer = new UnityPlayer(this);

                            int glesMode = m_UnityPlayer.getSettings().getInt("gles_mode", 1);

                            boolean trueColor8888 = false;

                            m_UnityPlayer.init(glesMode, trueColor8888);

                            setContentView(R.layout.activity_main);

                            //This is my relative layout
                            RelativeLayout layout = (RelativeLayout) findViewById(R.id.relativelayout2);    
//Relativelayout width is 750dp and height is 640dp.

                            LayoutParams lp = new LayoutParams (750, 640);

//Iam adding unityview to layout here

                            layout.addView(m_UnityPlayer.getView(), 0, …
Run Code Online (Sandbox Code Playgroud)

android

7
推荐指数
1
解决办法
6642
查看次数

标签 统计

android ×2