如何获取三星公司某一款手机的android源码下载

&&&&各个大公司的android面试题(联想,三星。HTC)即面试技巧
&各个大公司的android面试题(联想,三星。HTC)即面试技巧
各个大公司的android面试题(联想、三星、HTC等等),以及面试技巧
若举报审核通过,可奖励20下载分
被举报人:
jinlong_lou
举报的资源分:
请选择类型
资源无法下载
资源无法使用
标题与实际内容不符
含有危害国家安全内容
含有反动色情等内容
含广告内容
版权问题,侵犯个人或公司的版权
*详细原因:
VIP下载&&免积分60元/年(1200次)
您可能还需要
Q.为什么我点的下载下不了,但积分却被扣了
A. 由于下载人数众多,下载服务器做了并发的限制。若发现下载不了,请稍后再试,多次下载是不会重复扣分的。
Q.我的积分不多了,如何获取积分?
A. 获得积分,详细见。
完成任务获取积分。
论坛可用分兑换下载积分。
第一次绑定手机,将获得5个C币,C币可。
关注并绑定CSDNID,送10个下载分
下载资源意味着您已经同意遵守以下协议
资源的所有权益归上传用户所有
未经权益所有人同意,不得将资源中的内容挪作商业或盈利用途
CSDN下载频道仅提供交流平台,并不能对任何下载资源负责
下载资源中如有侵权或不适当内容,
本站不保证本站提供的资源的准确性,安全性和完整性,同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
移动开发下载排行
您当前C币:0&&&可兑换 0 下载积分
兑换下载分:&
消耗C币:0&
立即兑换&&
兑换成功你当前的下载分为 。前去下载资源
你下载资源过于频繁,请输入验证码
如何快速获得积分?
你已经下载过该资源,再次下载不需要扣除积分
各个大公司的android面试题(联想,三星。HTC)即面试技巧
所需积分:5
剩余积分:0
扫描微信二维码精彩活动、课程更新抢先知
VIP会员,免积分下载
会员到期时间:日
剩余下载次数:1000
各个大公司的android面试题(联想,三星。HTC)即面试技巧
剩余次数:&&&&有效期截止到:
你还不是VIP会员VIP会员享免积分 . 专属通道极速下载
VIP下载次数已满VIP会员享免积分 . 专属通道极速下载,请继续开通VIP会员
你的VIP会员已过期VIP会员享免积分 . 专属通道极速下载,请继续开通VIP会员android 特殊用户通知用法汇总--Notification源码分析
  一直用的android手机,用过这么多的app,平时也会遇到有趣的通知提醒,在这里先总结两种吧,notification和图标数字,有的以后看到再研究。还有,推广一下哈,刚刚建立一个Q群,有兴趣的加一下,一起成长。
  将一个notification的setOngoing属性设置为true之后,notification就能够一直停留在系统的通知栏直到cancel或者应用退出。所以有的时候需要实时去根据情景动态改变notification,这里以一个定时器的功能为例,需要每隔1s去更新一下notification,具体效果:
非常简单的功能,代码也很简单:
&CODE class=&hljs java&&private T
private TimerT
if (timer != null)
timer = new Timer(&time&);
task = new TimerTask() {
public void run() {
showDynamicNotification();
timer.scheduleAtFixedRate(task, 0, 1000);
private void showDynamicNotification() {
L.i(&show dynamic notification&);
mBuilder = new NotificationCompat.Builder(NotificationActivity.this);
RemoteViews view = new RemoteViews(getPackageName(), R.layout.layout_notification);
view.setTextViewText(R.id.tv_number, parseDate());
view.setImageViewResource(R.id.iv_icon, R.mipmap.ic_launcher);
Intent intent = new Intent(NOTIFY_ACTION);
PendingIntent pendingIntent = PendingIntent.getBroadcast(NotificationActivity.this,
1000, intent, PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setSmallIcon(R.mipmap.ic_launcher)
.setContentIntent(pendingIntent)
.setTicker(&you got a new message&)
.setOngoing(true)
.setContent(view);
notification = mBuilder.build();
notificationManager.notify(NOTIFY_ID2, notification);
private String parseDate() {
SimpleDateFormat format = new SimpleDateFormat(&yyyy hh:mm:ss&, Locale.getDefault());
return format.format(System.currentTimeMillis());
  需要注意的是Notification.Builder 是 Android 3.0 (API 11) 引入的,为了兼容低版本,我们一般使用 Support V4 包提供的 NotificationCompat.Builder 来构建 Notification。要想动态更新notification,需要利用 NotificationManager.notify() 的 id 参数,该 id 在应用内需要唯一(如果不唯一,在有些4.x的手机上会出现pendingIntent无法响应的问题,在红米手机上出现过类似情况),要想更新特定 id 的通知,只需要创建新的 notification,并触发与之前所用 id 相同的 notification,如果之前的通知仍然可见,则系统会根据新notification 对象的内容更新该通知,相反,如果之前的通知已被清除,系统则会创建一个新通知。
  在这个例子中使用的是完全自定义的remoteViews,remoteViews和普通view的更新机制不一样,网上资料很多,感兴趣的可以去仔细了解。还有一个就是PendingIntent,这就不详细介绍了,这里简单列一下PendingIntent的4个flag的作用
FLAG_CANCEL_CURRENT:如果构建的PendingIntent已经存在,则取消前一个,重新构建一个。FLAG_NO_CREATE:如果前一个PendingIntent已经不存在了,将不再构建它。FLAG_ONE_SHOT:表明这里构建的PendingIntent只能使用一次。FLAG_UPDATE_CURRENT:如果构建的PendingIntent已经存在,则替换它,常用。
  Notification有两种视觉风格,一种是标准视图(Normal view)、一种是大视图(Big view)。标准视图在Android中各版本是通用的,但是对于大视图而言,仅支持Android4.1+的版本,比如邮件,音乐等软件就会使用到这种大视图样式的扩展通知栏,系统提供了setStyle()函数用来设置大视图模式,一般情况下有三种模式提供选择:
NotificationCompat.BigPictureStyle, 在细节部分显示一个256dp高度的位图NotificationCompat.BigTextStyle,在细节部分显示一个大的文本块。NotificationCompat.InboxStyle,在细节部分显示一段行文本。  在21版本之后增加了一个Notification.MediaStyle,这个可以达到类似
的效果,基本和一些主流媒体播放器的界面类似了,在这就不具体介绍了,提供一篇资料:controllingMedia
  如果不使用上面的几种style,完全自定义布局也是可以的,例如实现:
  在这我就以一个简单的实现为例,效果如下:
RemoteViews smallView = new RemoteViews(getPackageName(), R.layout.layout_notification);
smallView.setTextViewText(R.id.tv_number, parseDate());
smallView.setImageViewResource(R.id.iv_icon, R.mipmap.ic_launcher);
mBuilder = new NotificationCompat.Builder(NotificationActivity.this);
mBuilder.setSmallIcon(R.mipmap.ic_launcher)
.setNumber((int) (Math.random() * 1000))
//No longer displayed in the status bar as of API 21.
.setTicker(&you got a new message&)
.setDefaults(Notification.DEFAULT_SOUND
| Notification.DEFAULT_VIBRATE | Notification.DEFAULT_LIGHTS)
.setDeleteIntent()
.setAutoCancel(true)
.setWhen(0)
.setPriority(NotificationCompat.PRIORITY_LOW);
intent = new Intent(NOTIFY_ACTION);
pendingIntent = PendingIntent.getBroadcast(NotificationActivity.this,
1000, intent, PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(pendingIntent);
//在5.0版本之后,可以支持在锁屏界面显示notification
if (Build.VERSION.SDK_INT &= Build.VERSION_CODES.LOLLIPOP){
mBuilder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
notification = mBuilder.build();
notification.contentView = smallV
//如果系统版本 &= Android 4.1,设置大视图 RemoteViews
if (Build.VERSION.SDK_INT &= Build.VERSION_CODES.JELLY_BEAN) {
RemoteViews view = new RemoteViews(getPackageName(), R.layout.layout_big_notification);
view.setTextViewText(R.id.tv_name, &我是名字1我是名字2我是名字3我是名字4我是名字5我是名字6我是名字7我是名字&);
view.setOnClickPendingIntent(R.id.btn_click_close,
PendingIntent.getBroadcast(NotificationActivity.this, 1001,
new Intent(CLICK_ACTION), PendingIntent.FLAG_UPDATE_CURRENT));
//textview marquee property is useless for bigContentView
notification.bigContentView =
notificationManager.notify(NOTIFY_ID3, notification);
&framelayout android:layout_height="150dp" android:layout_width="match_parent"&
&/framelayout&
  这里有几点需要着重说明一下
setTicker函数在21版本之后已经Deprecated了,没有效果。监听notification删除函数setDeleteIntent是在11版本后新增的,而且setAutoCancel为true后,该函数会失效。setPriority函数用来给notification设置优先级,上面给的google文档中有很详细的介绍。21版本之后,可以支持在锁屏界面显示notification,这个在google文档中也有介绍,这个体验对于我个人来说感触很深,对于短信等私密性通知可以隐藏,但是对于一般毫无隐私的应用通知,就可以设置其为public,省去用户解锁,下拉通知栏的操作。自定义大图模式也是将自定义的RemoteViews赋值给notification.bigContentView变量,而且这个功能也只是在api16(4.1)之后生效。大图模式高度的设置有些奇怪,在上面的xml文件中,LinearLayout设置高度是无效的,必须要套一层FrameLayout,设置FrameLayout的高度才行,貌似定义最外层的LinearLayout的layoutParams是无效的。在bigContentView中是无法实现textview的marquee效果,而且事实也很奇怪,单独使用contentView,传入的remoteViews中的textview的marquee属性是好用的,但是一旦设置了bigContentView,contentView中的textview属性也失效了,这点使用的时候要注意。
  这种效果大家应该在微信中看的很多,其实实现也很简单:
RemoteViews headsUpView = new RemoteViews(getPackageName(), R.layout.layout_heads_up_notification);
intent = new Intent(NOTIFY_ACTION);
pendingIntent = PendingIntent.getBroadcast(NotificationActivity.this,
1000, intent, PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder = new NotificationCompat.Builder(NotificationActivity.this);
mBuilder.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle(&this is notification title test&)
.setContentText(&this is notification text test&)
.setNumber((int) (Math.random() * 1000))
.setTicker(&you got a new message&)
//must set pendingintent for this notification, or will be crash
.setContentIntent(pendingIntent)
.setDefaults(Notification.DEFAULT_SOUND
| Notification.DEFAULT_VIBRATE | Notification.DEFAULT_LIGHTS)
.setAutoCancel(true)
.setWhen(0);
notification = mBuilder.build();
if (Build.VERSION.SDK_INT &= 21) {
notification.priority = Notification.PRIORITY_MAX;
notification.headsUpContentView = headsUpV
notificationManager.notify(NOTIFY_ID1, notification);
notification常见问题总结
  1.通过notification打开activity的时候,就要涉及到保存用户导航的问题,这个时候就要使用到activity task的相关内容了,我以前写过一篇博客中有介绍到activity task的内容:android深入解析Activity的launchMode启动模式,Intent Flag,taskAffinity,感兴趣的可以去看看。那么要实现点击notification打开指定activity,就需要设置相关的pendingIntent,有两种特殊的情况需要说明一下:  
第一种是需要打开该activity的整个task栈,也就是说父activity也需要同时全部打开,而且按照次序排列在task栈中。但是这里会有一个问题,它在打开整个activity栈之前会先清空原先的activity task栈,所以最后在task栈中只剩下相关的几个activity,举个例子我要打开A-&B-&C的activity栈,但是我原先的activity栈中有D和C这两个activity,系统会直接按顺序关闭D和C这两个activity,接着按顺序打开A-&B-&C,这种情况在使用的时候需要注意。第二种是直接打开一个activity在一个单独的task栈中这种情况会生成两个task栈,这两种情况在google官方文档中已经详细介绍了:
  2.我在以前的博客中曾经介绍过一个notification图标变成白块的问题:android5.0状态栏图标变成白色,这个问题在国产的很多rom中自己解决了,例如小米,锤子等,但是例如HTC和三星等rom仍然是有这样的问题,要重视起来啊 
  3.在2.3的时候直接使用
RemoteViews rvMain = new RemoteViews(context.getPackageName(), R.layout.notification_layout);
//TODO rvMain...
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
.setContent(rvMain);
// TOOD ...
是无效的,需要换一种方式:
RemoteViews rvMain = new RemoteViews(context.getPackageName(), R.layout.notification_layout);
//TODO rmMain...
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
.setContent(rvMain);
// TOOD ...
Notification notification = builder.build();
if(Build.VERSION.SDK_INT &= 10){
notification.contentView = rvM
4.通知栏上的操作事件:
setContentIntent():用户点击通知时触发setFullScreenIntent()://TODO 这个在通知显示的时候会被调用setDeleteIntent():用户清除通知时触发,可以是点击清除按钮,也可以是左右滑动删除(当然了,前提是高版本)2.3及以下是无法处理自定义布局中的操作事件的,这样我们就不要去考虑增加自定义按钮了。
notification源码解析
  分析一下源码,以NotificationManager.notify为入口进行分析:
INotificationManager service = getService();
service.enqueueNotificationWithTag(pkg, mContext.getOpPackageName(), tag, id,
stripped, idOut, UserHandle.myUserId());
getService()函数:
static public INotificationManager getService()
if (sService != null) {
IBinder b = ServiceManager.getService(&notification&);
sService = INotificationManager.Stub.asInterface(b);
该函数通过ServiceManager.getService(&notification&)获取了INotificationManager的Binder对象,用来进行跨进程通信,这里获取的Binder对象就是NotificationManagerService,这里涉及的两个类要介绍一下,StatusBarManagerService和NotificationManagerService,这两个service都会在frameworks/base/services/java/com/android/server/SystemServer.java文件里面进行启动的:
class ServerThread extends Thread {
public void run() {
StatusBarManagerService statusBar =
NotificationManagerService notification =
statusBar = new StatusBarManagerService(context, wm);
ServiceManager.addService(Context.STATUS_BAR_SERVICE, statusBar);
notification = new NotificationManagerService(context, statusBar, lights);
ServiceManager.addService(Context.NOTIFICATION_SERVICE, notification);
我在早期的博客中介绍过SystemServer,system_server子进程是zygote通过forkSystemServer函数创建的,感兴趣的可以去看看android启动过程详细讲解。上面的代码就调用到了NotificationManagerService的enqueueNotificationWithTag方法,enqueueNotificationWithTag方法会调用到enqueueNotificationInternal方法,这个方法就是核心了,我们抽取其中比较重要的代码分析一下:
void enqueueNotificationInternal(final String pkg, final String opPkg, final int callingUid,
final int callingPid, final String tag, final int id, final Notification notification,
int[] idOut, int incomingUserId) {
//------这里会做一个限制,除了系统级别的应用之外,其他应用的notification数量会做限制,
//------用来放置DOS攻击导致的泄露
// Limit the number of notifications that any given package except the android
// package or a registered listener can enqueue.
Prevents DOS attacks and deals with leaks.
//------post到工作handler中进行工作
mHandler.post(new Runnable() {
public void run() {
synchronized (mNotificationList) {
// === Scoring ===
//------审查参数priority
// 0. Sanitize inputs
notification.priority = clamp(notification.priority, Notification.PRIORITY_MIN,
Notification.PRIORITY_MAX);
//------初始化score
// 1. initial score: buckets of 10, around the app [-20..20]
final int score = notification.priority * NOTIFICATION_PRIORITY_MULTIPLIER;
//------将前面传递进来的Notification封装成一个StatusBarNotification对象,然后
//------和score封装成一个NotificationRecord对象,接着会调用handleGroupedNotificationLocked
//------方法,看能否跳过下一步操作,额外的会对downloadManager进行单独处理
// 2. extract ranking signals from the notification data
//------主要是统计notification的各种行为,另外将该上面封装好的NotificationRecord对象
//------加入到mNotificationList中,然后排序,排序外后,如果notification设置了smallIcon,
//------调用所有NotificationListeners的notifyPostedLocked方法,通知有新的notification,
//------传入的参数为上面封装成的StatusBarNotification对象。
// 3. Apply local rules
mRankingHelper.sort(mNotificationList);
if (notification.getSmallIcon() != null) {
StatusBarNotification oldSbn = (old != null) ? old.sbn :
mListeners.notifyPostedLocked(n, oldSbn);
//通知status bar显示该notification
buzzBeepBlinkLocked(r);
notifyPostedLocked方法中会继续post到工作handler中,在该工作handler中调用notifyPosted方法,notifyPosted方法很简单,也是通过Binder调用到了NotificationListenerService中,这个NotificationListenerService类很实用,它可以继承,用来监听系统notification的各种动作:Android 4.4 KitKat NotificationManagerService使用详解与原理分析(一)__使用详解。通知完成,最后异步操作就是调用buzzBeepBlinkLocked()方法去显示该notification了,这个函数也很长,但是职责很明确,确认是否需要声音,震动和闪光,如果需要,那么就发出声音,震动和闪光:
private void buzzBeepBlinkLocked(NotificationRecord record) {
// Should this notification make noise, vibe, or use the LED?
// If we're not supposed to beep, vibrate, etc. then don't.
if (disableEffects == null
&& (!(record.isUpdate
&& (notification.flags & Notification.FLAG_ONLY_ALERT_ONCE) != 0 ))
&& (record.getUserId() == UserHandle.USER_ALL ||
record.getUserId() == currentUser ||
mUserProfiles.isCurrentProfile(record.getUserId()))
&& canInterrupt
&& mSystemReady
&& mAudioManager != null) {
if (DBG) Slog.v(TAG, &Interrupting!&);
sendAccessibilityEvent(notification, record.sbn.getPackageName());
// should we use the default notification sound? (indicated either by
// DEFAULT_SOUND or because notification.sound is pointing at
// Settings.System.NOTIFICATION_SOUND)
// vibrate
// Does the notification want to specify its own vibration?
if (buzz || beep || blink) {
EventLogTags.writeNotificationAlert(record.getKey(),
buzz ? 1 : 0, beep ? 1 : 0, blink ? 1 : 0);
mHandler.post(mBuzzBeepBlinked);
最后将mBuzzBeepBlinked post到工作handler,最后会调用到mStatusBar.buzzBeepBlinked(),mStatusBar是StatusBarManagerInternal对象,这个对象是在StatusBarManagerService中初始化,所以最后调用到了StatusBarManagerService中StatusBarManagerInternal的buzzBeepBlinked()方法:
public void buzzBeepBlinked() {
if (mBar != null) {
mBar.buzzBeepBlinked();
} catch (RemoteException ex) {
  虽然说这是iOS上的风格,但是在某些手机上还是支持的,比如三星和HTC(m8t,6.0)的有些手机都可以,小米手机是个特例,它是根据notification的数量来自动生成的。
  一般情况下,HTC和三星可以使用下面的函数生成
public static void setBadge(Context context, int count) {
String launcherClassName = getLauncherClassName(context);
if (launcherClassName == null) {
Intent intent = new Intent(&android.intent.action.BADGE_COUNT_UPDATE&);
intent.putExtra(&badge_count&, count);
intent.putExtra(&badge_count_package_name&, context.getPackageName());
intent.putExtra(&badge_count_class_name&, launcherClassName);
context.sendBroadcast(intent);
public static String getLauncherClassName(Context context) {
PackageManager pm = context.getPackageManager();
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
List resolveInfos = pm.queryIntentActivities(intent, 0);
for (ResolveInfo resolveInfo : resolveInfos) {
String pkgName = resolveInfo.activityInfo.applicationInfo.packageN
if (pkgName.equalsIgnoreCase(context.getPackageName())) {
String className = resolveInfo.activityInfo.
return classN
(window.slotbydup=window.slotbydup || []).push({
id: '2467140',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467141',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467142',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467143',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467148',
container: s,
size: '1000,90',
display: 'inlay-fix'如何获取三星公司某一款手机的android源码
[问题点数:40分]
如何获取三星公司某一款手机的android源码
[问题点数:40分]
不显示删除回复
显示所有回复
显示星级回复
显示得分回复
只显示楼主
本帖子已过去太久远了,不再提供回复功能。}

我要回帖

更多关于 git获取android源码 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信