Android code wiki
Android code wiki
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.cts.permissionapp;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import java.lang.Override;
/**
* A simple activity that requests permissions and returns the result.
*/
public class PermissionActivity extends Activity {
;
private String mPermission;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Intent received = getIntent();
Log.d(TAG, "Started with " + received);
final String action = received.getAction();
mPermission = received.getStringExtra(EXTRA_PERMISSION);
if (ACTION_REQUEST_PERMISSION.equals(action)) {
Log.d(TAG, "Requesting permission " + mPermission);
requestPermissions(new String[] {mPermission}, PERMISSIONS_REQUEST_CODE);
} else if (ACTION_CHECK_HAS_PERMISSION.equals(action)) {
Log.d(TAG, "Checking permission " + mPermission);
sendResultBroadcast(checkSelfPermission(mPermission));
} else {
Log.w(TAG, "Unknown intent received: " + received);
finish();
}
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions,
int[] grantResults) {
if (requestCode != PERMISSIONS_REQUEST_CODE ||
permissions.length != 1 ||
!permissions[].equals(mPermission)) {
Log.d(TAG, "Received wrong permissions result");
sendResultBroadcast(PERMISSION_ERROR);
} else {
Log.d(])]);
}
}
private void sendResultBroadcast(int result) {
Log.d(TAG, "Sending result broadcast: " + result);
Intent broadcast = new Intent(ACTION_PERMISSION_RESULT);
broadcast.putExtra(EXTRA_GRANT_STATE, result);
sendBroadcast(broadcast);
finish();
}
}

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="我是预览的文字,编译我就消失啦" />
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/listView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fastScrollAlwaysVisible="true"
tools:fastScrollAlwaysVisible="false" />
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:layout_height="match_parent"
tools:targetApi="M"
tools:text="Mastering ToolsNs" />
</LinearLayout>
tools:locale="es">
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<fragment
android:name="com.alexsimo.mastertoolsnamespace.BooksFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout="@layout/fragment_books" />
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<fragment
android:name="com.alexsimo.mastertoolsnamespace.BooksFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout="@layout/fragment_book" />
</LinearLayout>
tools:listitem=“”
tools:listheader,tools:listfooter,预览ListView是非常有用的,但是对于RecyclerView 没有header和footer)<android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/list"
android:name="com.alexsimo.mastertoolsnamespace.BooksFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
app:layoutManager="LinearLayoutManager"
tools:context="com.alexsimo.mastertoolsnamespace.BooksFragment"
tools:listitem="@layout/fragment_book_list_item" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageView"
android:layout_width="150dp"
android:layout_height="150dp"
tools:src="@android:drawable/ic_media_play" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/text_margin"
android:textAppearance="?attr/textAppearanceListItem"
tools:text="My book title" />
<TextView
android:id="@+id/content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/text_margin"
android:textAppearance="?attr/textAppearanceListItem"
tools:text="My book description" />
</LinearLayout>
</LinearLayout>
activity_main
,如下:
android:windowSoftInputMode="adjustResize"
float density = getResources().getDisplayMetrics().density;
0xFF33B5E5, 0xFFAA66CC, 0xFF99CC00, 0xFFFFBB33, 0xFFFF4444,
0xFF0099CC, 0xFF9933CC, 0xFF669900, 0xFFFF8800, 0xFFCC0000
setBackground(states);
else
setBackgroundDrawable(states);
def getGitVersion() {
try {
return 'git rev-parse --short HEAD'.execute().text.trim()
} catch (Throwable th) {
return "";
}
}
android {
compileSdkVersion 23
buildToolsVersion buildToolsVer
useLibrary 'org.apache.http.legacy'
defaultConfig {
minSdkVersion 9
targetSdkVersion 23
buildConfigField "String", "GIT_REVISION", "\"${getGitVersion()}\""
buildConfigField "String", "BUILD_DATE", "\"${new Date().toLocaleString()}\"";
}
signingConfigs {
debug { storeFile file("debug.keystore") }
release {
storeFile file('release.keystore')
storePassword 'thisiskeystorepassword'
keyAlias 'nim_demo'
keyPassword 'thisiskeypassword'
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
manifestPlaceholders = [ AMAP_KEY:"09fd4efd3e28e9bf1f449ecec7d34bfe" ]
}
release {
minifyEnabled true
zipAlignEnabled true
proguardFile('proguard.cfg')
signingConfig signingConfigs.release
manifestPlaceholders = [ AMAP_KEY:"ee20324fba1c7f4ad7a4a207e7f08e8d" ]
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res', 'res-avchat', 'res-chatroom']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs', 'libs-sdk']
}
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
dexOptions {
incremental true
preDexLibraries false
jumboMode true
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar', exclude: ['android-support-*.jar'])
compile project(path: ':uikit')
}



Android code wiki的更多相关文章
- android code 和js的交互
小弟现在需要android code 和js的交互.出现了问题,求大家带一带啊. 我的页面:<!DOCTYPE html><html lang="en">& ...
- 安卓自动生成代码插件-Android code Generator(转)
编辑推荐:稀土掘金,这是一个针对技术开发者的一个应用,你可以在掘金上获取最新最优质的技术干货,不仅仅是Android知识.前端.后端以至于产品和设计都有涉猎,想成为全栈工程师的朋友不要错过! 介绍 A ...
- Robolectric Test-Drive Your Android Code
Running tests on an Android emulator or device is slow! Building, deploying, and launching the app o ...
- android code bbs for developer
http://bbs.aiyingli.com/forum.php http://www.eoeandroid.com/ http://www.javaapk.com/demo http://www. ...
- Android Migrate Android Code
近期在更改程序架构的时候,用引用Library的方式实现程序的共享化过程中发现R.id.xx的文件不能够在 switch cases 中使用 看代码提示,如下信息: As of ADT 14, r ...
- Android开发的插件Code Generator与LayoutCreator的安装与使用,提升你的开发效率
前言 大家好,给大家带来Android开发的插件Code Generator与LayoutCreator的安装与使用,提升你的开发效率的概述,希望你们喜欢 学习目标 掌握两个插件的安装和使用,能够实现 ...
- 我的Android进阶之旅------>经典的大牛博客推荐(排名不分先后)!!
本文来自:http://blog.csdn.net/ouyang_peng/article/details/11358405 今天看到一篇文章,收藏了很多大牛的博客,在这里分享一下 谦虚的天下 柳志超 ...
- 掘金 Android 文章精选合集
掘金 Android 文章精选合集 掘金官方 关注 2017.07.10 16:42* 字数 175276 阅读 50053评论 13喜欢 669 用两张图告诉你,为什么你的 App 会卡顿? - A ...
- android动态加载
转载自: http://www.cnblogs.com/over140/archive/2012/03/29/2423116.html http://www.cnblogs.com/over140/a ...
随机推荐
- [Leetcode] Container With Most Water ( C++)
题目: Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, a ...
- JOSN的stringify()和parse()方法
JOSN的stringify()和parse()方法使用,stringify()把对象序列化,parse()把JSON字符串解析为js对象 <script> var book = { ti ...
- The FastCGI process exited unexpectedly
ERROR:HTTP Error 500.0 - Internal Server Error D:\Program Files\php\php-cgi.exe - The FastCGI proces ...
- 1009 Enigma
本题的重点是理解清楚题意并能代码模拟.形式是二战德国密码机,和数据结构.算法联系较少. #include <stdio.h> #include <string.h> int m ...
- 【Git】代码托管-从基本设置开始
Git是现在比较火的一款代码托管工具,之前也有在使用GitHub,是用GitHub for windows一个图形管理的界面,如果没有这个图形控制界面的话我估计自己又要放弃了.用BASH命令来实现托管 ...
- BZOJ 1064 假面舞会
http://www.lydsy.com/JudgeOnline/problem.php?id=1064 思路:第一眼看的时候以为是差分约束,但是是做不了的,不过能保证的就是这题绝对是图论题...(废 ...
- C# System.Object基类
System.Object 基类 System.Object在.Net中是所有类型的基类,任何类型都直接或间接地继承自System.Object.没有指定基类的类型都默认继承于System.Objec ...
- SqlServer IF Exists([database]|[table]|[prop]) / Column([Operation])
*************************** --判断数据库是否存在 IF EXISTS (SELECT * FROM MASTER..sysdatabases WHERE NAME = ' ...
- tar解压错误
# tar -zxvf aaa.tar.gz tar: This does not look like a tar archive tar: Skipping to next header ...
- android sdk 如何重新生成debug.keystore
1)首先你要确定你安装的JDK位置,Windows->Preferences->Java->Installed JREs,你可以看到是Jre的location,再在dos cmd模式 ...