10.10笔记,android通知栏兼容性,matches the given name 'android:Widget.Material.Button.Colored'.

来源:互联网 发布:绿茶软件园php源码 编辑:程序博客网 时间:2024/04/30 11:25

6.0通知栏去掉了
notification.setLatestEventInfo(context, tipTitle, msg, contentIntent);
方法
可以使用如下方法替换:
http://zhidao.baidu.com/link?url=aZe1zgBSBsf9xCYNpcz2fVAy1O1SqOoFSptNZdyLbs8DZVh0f7kbx4AsJ8UFqubdFR8xWmTwT7eTgG2yyp6UX07cMQ1MCxN6dWUZlQmUfLu

原始的:NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);            Notification notification = new Notification(                    R.drawable.ic_launcher, "title", System.currentTimeMillis());            notification.defaults = 0;            Uri uri = Uri.parse("http://baidu.com");            Intent intent = new Intent(Intent.ACTION_VIEW, uri);            intent.setComponent(null);            PendingIntent pi = PendingIntent.getActivity(                    getApplicationContext(), 0, intent, 0);            notification.setLatestEventInfo(getApplicationContext(), "title",                    "content", pi);            mNotificationManager.notify(1000, notification);V4的:NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);            NotificationCompat.Builder builder = new NotificationCompat.Builder(                    getApplicationContext());            builder.setSmallIcon(R.drawable.ic_launcher);            builder.setDefaults(0);            builder.setAutoCancel(true);            builder.setContentTitle("title");            builder.setContentText("content");            Uri uri = Uri.parse("http://baidu.com");            Intent intent = new Intent(Intent.ACTION_VIEW, uri);            intent.setComponent(null);            PendingIntent pendingIntent = PendingIntent.getActivity(                    getApplicationContext(), 0, intent, 0);            builder.setContentIntent(pendingIntent);            mNotificationManager.notify(1000, builder.build());

如果把版本提高至22以上出现这个问题
Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.Button.Colored’.
参考如下方法解决:
1.
http://stackoverflow.com/questions/26530415/error-in-styles-base-xml-file-android-app-no-resource-found-that-matches-the

Go to your Android SDK installed directory then extras > android > support > v7 > appcompat.in my case : D:\Software\adt-bundle-windows-x86-20140702\sdk\extras\android\support\v7\appcompatonce you are in appcompat folder ,check for project.properties file then change the value from default 19 to 21 as : target=android-21. save the file and then refresh your project. Then clean the project : In project tab , select clean option then select your project and clean... This will resolve the error. enjoy coding...

2.http://bbs.csdn.net/topics/391813146
改下build.gradle文件,将里面的compileSdkVersion改为23即可
gradle版本改为1.3.0

3.如果使用:
compile ‘com.google.android.gms:play-services:8.1.0’
出现:No resource found that matches the given name ‘android:Widget.Material.ActionButton’
请用旧版本修复

The last version of Google Play Services now uses appcompat-v7, so u can't use it with actionbarsherlock. You have to use only appcompat-v7 or the previous version of play services:compile 'com.google.android.gms:play-services:7.0.0'

参考:
http://www.07net01.com/2015/07/877878.html
http://stackoverflow.com/questions/18745803/gradle-error-attribute-xxx-has-already-been-defined-in-android-studio

4(终极方案,如果还是不行,那就没得玩了)到官网下载最新的sdk(如果sdk是从就版本更新上来的,问题依旧会出现,建议重新下载最新的)
http://developer.android.com/sdk/index.html

0 0
原创粉丝点击