当前位置: 编程技术>移动开发
本页文章导读:
▪ANT封装干净普通大众版本 ANT打包干净普通大众版本
前一篇文章,目录比较乱,且是think的文章摘要过来的,下面是我在自己的项目,没有其他模块。
build.xml
<project default="main" basedir=".">
<property file="../keystor.........
▪ 字符装置异步通知 字符设备异步通知driver:
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/cdev.h>
#include <linux/fs.h>
#include <linux/device.h>
#include <linux/syscalls.h>
#include <linux/.........
▪ 解决 GridView 中 Button按钮事件冲突有关问题 解决 GridView 中 Button按钮事件冲突问题在Button XML中增加 android:focusable="false" ......
[1]ANT封装干净普通大众版本
来源: 互联网 发布时间: 2014-02-18
ANT打包干净普通大众版本
build.sh
前一篇文章,目录比较乱,且是think的文章摘要过来的,下面是我在自己的项目,没有其他模块。
build.xml
<project default="main" basedir="."> <property file="../keystore.properties" /> <property name="apk-name" value="product" /> <property name="apk-version" value="latest" /> <property name="apk-market" value="dev" /> <property name="keystore" value="Reader.keystore" /> <property name="storepass" value="***"/> <property name="keypass" value="***"/> <property name="alias" value="chineseallreader"/> <property name="android-jar" value="/Users/mac/Desktop/androidsdk/android-sdk-macosx/platforms/android-8/android.jar" /> <target name="init"> <echo>start initing ... </echo> <mkdir dir="gen" /> <delete> <fileset dir="gen"></fileset> </delete> <mkdir dir="bin/classes" /> <delete> <fileset dir="bin/classes"></fileset> </delete> <mkdir dir="build/${apk-version}" /> <echo>finish initing. </echo> </target> <target name="main" depends="init"> <echo>generating R.java for project to dir gen (using aapt) ... </echo> <exec executable="aapt"> <arg value="package" /> <arg value="-m" /> <arg value="-J" /> <arg value="gen" /> <arg value="-M" /> <arg value="AndroidManifest.xml" /> <arg value="-S" /> <arg value="res" /> <arg value="-I" /> <arg value="${android-jar}" /> <arg value="--auto-add-overlay" /> </exec> <path id="project.libs"> <fileset dir="libs"> <include name="*.jar" /> </fileset> </path> <echo>compiling java files to class files (include R.java, library and the third-party jars) ... </echo> <javac destdir="bin/classes" bootclasspath="${android-jar}" includeantruntime="on" encoding="utf-8"> <src path="src" /> <src path="gen" /> <classpath refid="project.libs" /> </javac> <echo>packaging class files (include the third-party jars) to calsses.dex ... </echo> <exec executable="dx"> <arg value="--dex" /> <arg value="--output=bin/classes.dex" /> <arg value="bin/classes" /> <arg value="libs" /> </exec> <echo>packaging resource (include res, assets, AndroidManifest.xml, etc.) to res.zip ... </echo> <exec executable="aapt"> <arg value="package" /> <arg value="-f" /> <arg value="-M" /> <arg value="AndroidManifest.xml" /> <arg value="-S" /> <arg value="res" /> <arg value="-A" /> <arg value="assets" /> <arg value="-I" /> <arg value="${android-jar}" /> <arg value="-F" /> <arg value="bin/res.zip" /> <arg value="--auto-add-overlay" /> </exec> <echo>building unsigned.apk ... </echo> <exec executable="apkbuilder"> <arg value="bin/unsigned.apk" /> <arg value="-u" /> <arg value="-z" /> <arg value="bin/res.zip" /> <arg value="-f" /> <arg value="bin/classes.dex" /> <arg value="-nf"/> <arg value="libs"/> </exec> <echo>signing the unsigned apk to final product apk ... </echo> <exec executable="jarsigner"> <arg value="-keystore" /> <arg value="${keystore}" /> <arg value="-storepass" /> <arg value="${storepass}" /> <arg value="-keypass" /> <arg value="${keypass}" /> <arg value="-signedjar" /> <arg value="build/${apk-version}/${apk-name}_${apk-version}_${apk-market}.apk" /> <arg value="bin/unsigned.apk" /> <arg value="${alias}" /> </exec> <echo>done.</echo> </target> </project>
build.sh
#!/bin/bash basedir=$(cd "$(dirname "$0")";pwd) cd $basedir #============market follow=====by nil=== #androidmarket jiuyao tengxun anzhuowang #yingyonghui jifengwang youyishichang #Nduowang mumayi other #chineseall chineseall_wap #======================================= markets="androidmarket jiuyao tengxun anzhuowang yingyonghui jifengwang youyishichang Nduowang mumayi other chineseall chineseall_wap" for market in $markets do echo packaging 17kreader_3.5.3_$market.apk ... sed -i '' "s/\(android:value=\)\"\(.*\)\"\( android:name=\"UMENG_CHANNEL\"\)/\1\"$market\"\3/g" AndroidManifest.xml ant -Dapk-name=17kreader -Dapk-version=3.5.3 -Dapk-market=$market done
[2] 字符装置异步通知
来源: 互联网 发布时间: 2014-02-18
字符设备异步通知
App code:
driver:
#include <linux/kernel.h> #include <linux/module.h> #include <linux/cdev.h> #include <linux/fs.h> #include <linux/device.h> #include <linux/syscalls.h> #include <linux/uaccess.h> #include <linux/string.h> struct fpga_key_dev { struct cdev cdev; dev_t devno; char test[20]; struct class *fpga_key_class; struct fasync_struct *async_queue; int message_cdev_open; }; static int fpga_key_open(struct inode *node, struct file *fd) { struct fpga_key_dev *dev; printk("fpga_key_open()++\n"); printk("node->i_cdev = %x\n", (unsigned int)node->i_cdev); dev = container_of(node->i_cdev, struct fpga_key_dev, cdev); printk("dev->cdev = %x\n", (unsigned int)&dev->cdev); printk("dev = %x\n", (unsigned int)dev); if (!dev->message_cdev_open) { dev->message_cdev_open = 1; fd->private_data = dev; } else{ return -EFAULT; } printk("test[20] = %s\n",dev->test); printk("fpga_key_open()--\n"); return 0; } static ssize_t fpga_key_write(struct file *fd, const char __user *buf, size_t len, loff_t *ptr) { char temp_buffer [20]; int print_size = 0; struct fpga_key_dev *dev = fd->private_data; printk("fpga_key_wirte()++\n"); if(len > 20) print_size = 20; else print_size = len; printk("print_size = %d; len = %d\n", print_size, len); if(copy_from_user(temp_buffer, buf, print_size)) return -EFAULT; if (dev->async_queue) kill_fasync(&dev->async_queue, SIGIO, POLL_IN); printk("writing data:%s", temp_buffer); printk("fpga_key_wirte()--\n"); return print_size; } static ssize_t fpga_key_read(struct file *fd, char __user *buf, size_t len, loff_t *ptr) { char *temp_buffer = "Hello fpga_key_read !\n"; int print_size = 0; printk("fpga_key_read()++\n"); if(len > strnlen(temp_buffer,20)) print_size = strnlen(temp_buffer,20); else print_size = len; printk("print_size = %d; len = %d\n", print_size, len); if(copy_to_user(buf, temp_buffer, print_size)) return -EFAULT; printk("%s", temp_buffer); printk("fpga_key_read()--\n"); return print_size; } static int fpga_key_fasync(int fd, struct file *filp, int mode) { struct fpga_key_dev *dev = filp->private_data; printk("fpga_key_fasync()++\n"); fasync_helper(fd, filp, mode, &dev->async_queue); printk("fpga_key_fasync()--\n"); return 0; } static int fpga_key_release(struct inode *node, struct file *fd) { struct fpga_key_dev *dev = fd->private_data; printk("fpga_key_release()++\n"); dev->message_cdev_open = 0; fpga_key_fasync(-1, fd, 0); printk("fpga_key_release()--\n"); return 0; } struct file_operations meassage_operatons = { .owner = THIS_MODULE, .open = fpga_key_open, .write = fpga_key_write, .read = fpga_key_read, .fasync = fpga_key_fasync, .release = fpga_key_release, }; struct fpga_key_dev fpga_key_dev; static int __init fpga_key_init(void) { struct fpga_key_dev * dev; char * temp_char = "hello world\n"; printk("fpga_key_to_app_init(void)++\n"); dev = &fpga_key_dev; strcpy(dev->test, temp_char); printk("%s",dev->test); alloc_chrdev_region(&dev->devno, 0, 1, "fpga_key_to_app"); //dev->cdev = cdev_alloc(); cdev_init(&dev->cdev, &meassage_operatons); cdev_add(&dev->cdev, dev->devno, 1); printk("dev->cdev = %x\n", (unsigned int)&dev->cdev); printk("dev = %x\n", (unsigned int)dev); dev->fpga_key_class = class_create(THIS_MODULE, "fpga_key_class"); if(IS_ERR(dev->fpga_key_class)) { printk("Err: failed in creating class./n"); return -1; } device_create(dev->fpga_key_class, NULL, dev->devno, NULL, "fpga_key"); printk("fpga_key_to_app_init(void)--\n"); return 0; } static void __exit fpga_key_exit(void) { struct fpga_key_dev *dev = &fpga_key_dev; printk("fpga_key_to_app_exit(void)++\n"); device_destroy(dev->fpga_key_class, dev->devno); class_destroy(dev->fpga_key_class); cdev_del(&dev->cdev); unregister_chrdev_region(dev->devno, 1); printk("fpga_key_to_app_exit(void)--\n"); } module_init(fpga_key_init); module_exit(fpga_key_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Driver Monkey"); MODULE_DESCRIPTION("Test fpga_key to App");
App code:
#include<stdio.h> #include<sys/types.h> #include<sys/stat.h> #include<fcntl.h> #include<sys/select.h> #include<unistd.h> #include<signal.h> #include<string.h> unsigned int flag = 0; void sig_handler(int sig) { printf("%s\n",__FUNCTION__); flag++; } int main(void) { char r_buf[20]; char *w_buf = "hello write!\n"; int r_count = 0; int fd; int f_flags; flag++; fd=open("/dev/fpga_key",O_RDWR); if(fd<0) { perror("open"); return-1; } signal(SIGIO, sig_handler); fcntl(fd, F_SETOWN, getpid()); f_flags = fcntl(fd, F_GETFL); fcntl(fd, F_SETFL, FASYNC | f_flags); while(1) { printf("waiting \n"); sleep(2); if(flag > 3) break; printf("flag = %d\n", flag); write(fd, w_buf, strlen(w_buf)); } close(fd); return 0; }
[3] 解决 GridView 中 Button按钮事件冲突有关问题
来源: 互联网 发布时间: 2014-02-18
解决 GridView 中 Button按钮事件冲突问题
在Button XML中增加 android:focusable="false"
在Button XML中增加 android:focusable="false"
最新技术文章: