CFXIXI工作室首页
CF西西的博客 | andriod

Html5 使用 phonegap实现 图片下载

15. 二月 2014
使用phonegap插件 Downloader.rar (3.34 K, 下载次数:0) js文件做相应修改: function Downloader() {} Downloader.prototype.downloadFile = function(fileUrl, params, win, fail) {     //Make params hash optional.     if (!fail) win = params;     cordova.exec(win, fail, "Downloader", "downloadFile", [fileUrl, params]); }; /*PhoneGap.addConstructor(function() {     PhoneGap.addPlugin("downloader", new Downloader());     PluginManager.addService("Downloader", "com.cfxixi.dubaotianxia.Downloader"); });*/ if(!window.plugins) {     window.plugins = {}; } if (!window.plugins.downloader) {     window.plugins.downloader = new Downloader(); } 复制代码 调用方式: var openWin=1;                             window.plugins.downloader.downloadFile(weiboImgUrl, {overwrite: true},                                        function(res) {                                                                                  if(openWin==1){                                             $.alertMasker("下载成功,在您的"+res.dir+"文件路径下");                                             openWin=0;                                         }                                         else                                         {                                             return false;                                         }                                                                              }, function(error) {                                         $.alertMasker("该图片不能被下载");                                     }                                 ); 复制代码 如此便可在0/Download文件夹下找到图片

andriod

Android开发环境搭建 (基于Eclispe)

24. 二月 2013
转自:http://blog.csdn.net/univasity/article/details/7072324 JAVA运行环境(JDK安装)1. 下载并安装JDK(官网下载)2. 右键“我的电脑”->"属性",选择“高级”面板,点击下面的“环境变量”;3. 对“系统变量”做如下操作:1) 新建,    变量名:JAVA_HOME    变量值:JDK安装的目录(如,E:\Program Files\Java\jdk1.6.0_22)2) 修改Path,添加 %JAVA_HOME%\bin;3) 新建,    变量名:CLASSPATH    变量值:.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;Eclipse + Android SDK + ADT / MOTODEV Studio for Android1.下载Android SDK安装器并解压到任意目录(具体的SDK需要自行选择下载)。*可选:在“环境变量”的Path属性中添加SDK目录下的tools目录路径(如,X:\android-sdk-windows\tools),这样可以在使用命令行时更方便地调用tools目录下的工具。2.下载Eclipse(JAVA或J2EE版)并解压到任意目录下3.运行Eclipse,点开“帮助”菜单,选择“软件更新”菜单项,然后选择“查找并安装...“子项,新建更新站点如下:1)ADT方案(官方标准的开发配置)   名字:ADT Plugin   地址:https://dl-ssl.google.com/android/eclipse/   然后进行安装,并重启Eclipse.2)MOTODEV Studio for Android方案(由MOTO提供的开发插件,也是基于ADT,但整合了更丰富的开发工具。下载需要MOTO开发者账号,具体可参考官网)   Name:MOTODEV Studio for Android Plugin    Location:https://studio-android.motodevupdate.com/android/2.2       (会提示登录),选中MOTODEV Studio for Android,下载安装。4. "窗口(Window)"->"首选项(preferences)",在弹出的界面中找到"Android"(如果安装成功就能看到),设置好Android SDK的路径就OK了。设置模拟器在Eclipse中,打开"窗口(Window)"->"Android SDK and AVD Manager",选中左侧的"Virtual devices",然后点击右侧界面的"New"按钮进行新建。

andriod

安卓动态创建ListView对象

17. 十月 2012
 安卓开发qq群273843464欢迎您的加入~~ 思路就是实例化listview和linearLayout然后讲listView添加到linearLayout里面,最后记得将linearlayout用setContentView()方法刷新界面 m_ListView = new ListView(this); LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); m_ListView.setBackgroundColor(Color.BLACK); //在线性布局中添加listView m_LinearLayout.addView(m_ListView, param);

andriod, Android

安卓对linearlayout设置背景颜色

17. 十月 2012
 安卓开发qq群273843464欢迎您的加入~~ 在启动的class里面设置 LinearLayout m_LinearLayout; m_LinearLayout = new LinearLayout(this); m_LinearLayout.setOrientation(LinearLayout.VERTICAL); m_LinearLayout.setBackgroundColor(android.graphics.Color.BLACK);

andriod, Android

如何对textView设置背景色、字体和文字颜色

17. 十月 2012
  安卓开发qq群273843464欢迎您的加入~~ 如何对textView设置背景色、字体和文字颜色 首先是页面布局 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:id="@+id/textview" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> </LinearLayout> 的身份的 然后是设置方法取到textview对象后设置 textview = (TextView)this.findViewById(R.id.textview); String string = "TextViewʾ��ӭʹ�ã�"; textview.setTextColor(Color.RED); textview.setTextSize(20); textview.setBackgroundColor(Color.BLUE); textview.setText(string);

andriod, Android

安卓监听所有事件并全部变成回退键事件

17. 十月 2012
 安卓Developer QQ群273843464欢迎您的加入~~ public boolean onKeyDown(int keyCode, KeyEvent event) { KeyEvent key = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK); return super.onKeyDown(key.getKeyCode(), key); }

andriod

安卓监听点击事件

17. 十月 2012
安卓qq群273843464欢迎您的加入 安卓监听点击事件 public boolean onKeyDown(int keyCode, KeyEvent event) { DisplayToast(Integer.toString(keyCode)); switch (keyCode) { case KeyEvent.KEYCODE_DPAD_CENTER: DisplayToast("zhong"); break; case KeyEvent.KEYCODE_DPAD_UP: DisplayToast("shang"); break; case KeyEvent.KEYCODE_DPAD_DOWN: DisplayToast("xia"); break; case KeyEvent.KEYCODE_DPAD_LEFT: DisplayToast("zuo"); break; case KeyEvent.KEYCODE_DPAD_RIGHT: DisplayToast("you"); break; } return super.onKeyDown(keyCode, event); } /* �����������¼� */ public boolean onKeyUp(int keyCode, KeyEvent event) { DisplayToast(Integer.toString(keyCode)); switch (keyCode) { case KeyEvent.KEYCODE_DPAD_CENTER: DisplayToast("zhong"); break; case KeyEvent.KEYCODE_DPAD_UP: DisplayToast("shang"); break; case KeyEvent.KEYCODE_DPAD_DOWN: DisplayToast("xia"); break; case KeyEvent.KEYCODE_DPAD_LEFT: DisplayToast("zuo"); break; case KeyEvent.KEYCODE_DPAD_RIGHT: DisplayToast("you"); break; } return super.onKeyUp(keyCode, event); } public boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event) { return super.onKeyMultiple(keyCode, repeatCount, event); } /* �����¼� */ public boolean onTouchEvent(MotionEvent event) { int iAction = event.getAction(); if (iAction == MotionEvent.ACTION_CANCEL || iAction == MotionEvent.ACTION_DOWN || iAction == MotionEvent.ACTION_MOVE) { return false; } int x = (int) event.getX(); int y = (int) event.getY(); DisplayToast("���ʵ����꣺("+Integer.toString(x)+","+Integer.toString(y)+")"); return super.onTouchEvent(event); }

andriod

安卓显示一个一瞬间的提示

17. 十月 2012
 安卓qq群273843464欢迎您的加入 public void DisplayToast(String str) { Toast.makeText(this, str, Toast.LENGTH_SHORT).show(); }

andriod

安卓退出app

17. 十月 2012
安卓qq群273843464欢迎您的加入 Button button3 = (Button) findViewById(R.id.button3); button3.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { Activity01.this.finish(); } });

andriod

安卓Service播放音乐

17. 十月 2012
.java文件的代码 项目demo可去安卓开发qq群273843464下载 public class Activity01 extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button button_start = (Button)findViewById(R.id.start); Button button_stop = (Button)findViewById(R.id.stop); button_start.setOnClickListener(start); button_stop.setOnClickListener(stop); //startService(new Intent("com.yarin.Android.MUSIC")); } private OnClickListener start = new OnClickListener() { public void onClick(View v) { startService(new Intent("com.yarin.Android.MUSIC")); } }; //ֹͣ��ť private OnClickListener stop = new OnClickListener() { public void onClick(View v) { //ֹͣService stopService(new Intent("com.yarin.Android.MUSIC")); } }; }   Service代码: public class MusicService extends Service { private MediaPlayer player; public IBinder onBind(Intent arg0) { return null; } public void onStart(Intent intent, int startId) { super.onStart(intent, startId); player = MediaPlayer.create(this, R.raw.test); player.start(); } public void onDestroy() { super.onDestroy(); player.stop(); } } sdsdsds 然后是样式 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <Button android:id="@+id/start" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="开始播放"/> <Button android:id="@+id/stop" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="停止播放" /> </LinearLayout> 最后是manifest的注册 <activity android:name=".Activity01" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <service android:name=".MusicService"> <intent-filter> <action android:name="com.yarin.Android.MUSIC" /> <category android:name="android.intent.category.default" /> </intent-filter> </service>

andriod

简单android切换页面

17. 十月 2012
项目demo可去安卓开发qq群273843464下载 首先是src的中的.java文件 一个.java文件对应一个view,并且一个view有一个界面的xml public class Activity01 extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button button = (Button) findViewById(R.id.button1); button.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { Intent intent = new Intent(); intent.setClass(Activity01.this, Activity02.class); startActivity(intent); Activity01.this.finish(); } }); } } Activity01 切换时候实例化一个intent对象,用setClass的方法进行切换从activity1类切换到activity2类中 public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main2); /* findViewById(R.id.button2)ȡ�ò���main.xml�е�button2 */ Button button = (Button) findViewById(R.id.button2); button.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { Intent intent = new Intent(); intent.setClass(Activity02.this, Activity01.class); startActivity(intent); Activity02.this.finish(); } }); } 然后是样式xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <Button android:id="@+id/button1" android:layout_width="100px" android:layout_height="wrap_content" android:layout_x="100px" android:layout_y="80px" android:text="切换" > </Button> </LinearLayout> 样式2 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello2" > </TextView> <Button android:id="@+id/button2" android:layout_width="100px" android:layout_height="wrap_content" android:layout_x="100px" android:layout_y="80px" android:text="切换" > </Button> </LinearLayout>

andriod

制作安卓helloworld(第一个)程序

17. 十月 2012
项目demo可去安卓开发qq群273843464下载 1.在src下面的.java文件中onCreate构造函数里我们做两个操作,一个是记录log,还有一个是启动线程 private static final String TAG = "HelloAndroid"; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.v(TAG, "VERBOSE"); Log.d(TAG, "DEBUG"); Log.i(TAG, "INFO"); Log.w(TAG, "WARN"); Log.e(TAG, "ERROR"); setContentView(R.layout.main); } 其中我们打开的页面R.layout.main布局为 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> </LinearLayout> 如此便会出现values.xml中helloworld的文案

andriod

Andriod为App签名(为apk签名)

10. 十月 2012
原文:http://www.cnblogs.com/qianxudetianxia/archive/2011/04/09/2010468.html Android学习系列(1)--为App签名(为apk签名)   写博客是一种快乐,前提是你有所写,与人分享,是另一种快乐,前提是你有舞台展示,博客园就是这样的舞台。这篇文章是android开发人员的必备知识,是我特别为大家整理和总结的,不求完美,但是有用。 1.签名的意义  为了保证每个应用程序开发商合法ID,防止部分开放商可能通过使用相同的Package Name来混淆替换已经安装的程序,我们需要对我们发布的APK文件进行唯一签名,保证我们每次发布的版本的一致性(如自动更新不会因为版本不一致而无法安装)。 2.签名的步骤  a.创建key  b.使用步骤a中产生的key对apk签名 3.具体操作   方法一: 命令行下对apk签名(原理)  创建key,需要用到keytool.exe (位于jdk1.6.0_24\jre\bin目录下),使用产生的key对apk签名用到的是jarsigner.exe (位于jdk1.6.0_24\bin目录下),把上两个软件所在的目录添加到环境变量path后,打开cmd输入 D:\>keytool -genkey -alias demo.keystore -keyalg RSA -validity 40000 -keystore demo.keystore /*说明:-genkey 产生密钥 -alias demo.keystore 别名 demo.keystore -keyalg RSA 使用RSA算法对签名加密 -validity 40000 有效期限4000天 -keystore demo.keystore */ D:\>jarsigner -verbose -keystore demo.keystore -signedjar demo_signed.apk demo.apk demo.keystore /*说明:-verbose 输出签名的详细信息 -keystore demo.keystore 密钥库位置 -signedjar demor_signed.apk demo.apk demo.keystore 正式签名,三个参数中依次为签名后产生的文件demo_signed,要签名的文件demo.apk和密钥库demo.keystore.*/   注意事项:android工程的bin目录下的demo.apk默认是已经使用debug用户签名的,所以不能使用上述步骤对此文件再次签名。正确步骤应该是:在工程点击右键->Anroid Tools-Export Unsigned Application Package导出的apk采用上述步骤签名。   方法二:使用Eclipse导出带签名的apk  Eclipse直接能导出带签名的最终apk,非常方便,推荐使用,步骤如下:  第一步:导出。   第二步:创建密钥库keystore,输入密钥库导出位置和密码,记住密码,下次Use existing keystore会用到。   第三步:填写密钥库信息,填写一些apk文件的密码,使用期限和组织单位的信息。  第四步:生成带签名的apk文件,到此就结束了。  第五步:如果下次发布版本的时候,使用前面生成的keystore再签名。   第六步:Next,Next,结束!   方法三:使用IntelliJ IDEA导出带签名的apk   方法步骤基本和Eclipse相同,大概操作路径是:菜单Tools->Andrdoid->Export signed apk。 4.签名之后,用zipalign(压缩对齐)优化你的APK文件。  未签名的apk不能使用,也不能优化。签名之后的apk谷歌推荐使用zipalign.exe(位于android-sdk-windows\tools目录下)工具对其优化: D:\>zipalign -v 4 demo_signed.apk final.apk   如上,zipalign能够使apk文件中未压缩的数据在4个字节边界上对齐(4个字节是一个性能很好的值),这样android系统就可以使用mmap()(请自行查阅这个函数的用途)函数读取文件,可以在读取资源上获得较高的性能,  PS:1.在4个字节边界上对齐的意思就是,一般来说,是指编译器吧4个字节作为一个单位来进行读取的结果,这样的话,CPU能够对变量进行高效、快速的访问(较之前不对齐)。          2.对齐的根源:android系统中的Davlik虚拟机使用自己专有的格式DEX,DEX的结构是紧凑的,为了让运行时的性能更好,可以进一步用"对齐"进一步优化,但是大小一般会有所增加。 5.签名对你的App的影响。   你不可能只做一个APP,你可能有一个宏伟的战略工程,想要在生活,服务,游戏,系统各个领域都想插足的话,你不可能只做一个APP,谷歌建议你把你所有的APP都使用同一个签名证书。   使用你自己的同一个签名证书,就没有人能够覆盖你的应用程序,即使包名相同,所以影响有:  1) App升级。 使用相同签名的升级软件可以正常覆盖老版本的软件,否则系统比较发现新版本的签名证书和老版本的签名证书不一致,不会允许新版本安装成功的。  2) App模块化。android系统允许具有相同的App运行在同一个进程中,如果运行在同一个进程中,则他们相当于同一个App,但是你可以单独对他们升级更新,这是一种App级别的模块化思路。  3) 允许代码和数据共享。android中提供了一个基于签名的Permission标签。通过允许的设置,我们可以实现对不同App之间的访问和共享,如下: ? AndroidManifest.xml:<permission android:protectionLevel="normal" /> 其中protectionLevel标签有4种值:normal(缺省值),dangerous, signature,signatureOrSystem。简单来说,normal是低风险的,所有的App不能访问和共享此App。dangerous是高风险的,所有的App都能访问和共享此App。signature是指具有相同签名的App可以访问和共享此App。signatureOrSystem是指系统image中App和具有相同签名的App可以访问和共享此App,谷歌建议不要使用这个选项,因为签名就足够了,一般这个许可会被用在在一个image中需要共享一些特定的功能的情况下。  最后,请一定要记得保管好你的签名证书的两个密码,两个密码都不要告诉任何人,也不要把你的密钥库拷贝给别人,包括我!   

andriod

解决安卓web app “&”等特殊字符显示问题

7. 十月 2012
var aaa=“6&8” Ext.String.htmlEncode(aaa) lz用的是Sencha Touch的框架直接调用Ext.String.htmlEncode方法即可解决,也可以用游览器api的encode,异曲同工。

andriod, sencha touch 2

安卓如何禁止手机横屏?

28. 九月 2012
AndroidManifest.xml的activity中加入:android:screenOrientation="portrait"

andriod

安卓设置启动图片(splash)

26. 九月 2012
  super.setBooleanProperty("loadInWebView", true); super.setIntegerProperty("loadUrlTimeoutValue", 10000); super.setIntegerProperty("splashscreen",R.drawable.loding640920); super.loadUrl("file:///android_asset/www/index.html",3000);

andriod

Phonegap安卓如何通过点击Contact获得联系人列表的名字和电话

31. 七月 2012
Phonegap Andriod 交流 QQ 群 250395324欢迎您的加入 项目源代码可去我的qq群共享下载 1.引入ContactView.java package com.tricedesigns; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.app.Activity; import android.content.Intent; import android.database.Cursor; import android.net.Uri; import android.provider.ContactsContract; import com.phonegap.api.Plugin; import com.phonegap.api.PluginResult; public class ContactView extends Plugin { private static final int PICK_CONTACT = 1; private String callback; @Override public PluginResult execute(String action, JSONArray args, String callbackId) { startContactActivity(); PluginResult mPlugin = new PluginResult(PluginResult.Status.NO_RESULT); mPlugin.setKeepCallback(true); this.callback = callbackId; return mPlugin; } public void startContactActivity() { Intent intent = new Intent(Intent.ACTION_PICK); intent.setType(ContactsContract.Contacts.CONTENT_TYPE); this.ctx.startActivityForResult((Plugin) this, intent, PICK_CONTACT); } @Override public void onActivityResult(int reqCode, int resultCode, Intent data) { String name = null; String number = null; String email = null; switch (reqCode) { case (PICK_CONTACT): if (resultCode == Activity.RESULT_OK) { Uri contactData = data.getData(); Cursor c = this.ctx.managedQuery(contactData, null, null, null, null); if (c.moveToFirst()) { String ContactID = c.getString(c .getColumnIndex(ContactsContract.Contacts._ID)); String hasPhone = c.getString(c.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER)); if (Integer.parseInt(hasPhone) == 1) { Cursor phoneCursor = this.ctx.managedQuery( ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + "='" + ContactID + "'", null, null); while (phoneCursor.moveToNext()) { number = phoneCursor .getString(phoneCursor .getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)); } } // get email address Cursor emailCur = this.ctx.managedQuery( ContactsContract.CommonDataKinds.Email.CONTENT_URI, null, ContactsContract.CommonDataKinds.Email.CONTACT_ID + "='" + ContactID + "'", null,null); while (emailCur.moveToNext()) { // This would allow you get several email addresses // if the email addresses were stored in an array email = emailCur.getString( emailCur.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA)); //String emailType = emailCur.getString( // emailCur.getColumnIndex(ContactsContract.CommonDataKinds.Email.TYPE)); } emailCur.close(); name = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); JSONObject contactObject = new JSONObject(); try { contactObject.put("name", name); contactObject.put("phone", number); contactObject.put("email", email); } catch (JSONException e) { e.printStackTrace(); } this.success(new PluginResult(PluginResult.Status.OK, contactObject), this.callback); } } break; } } } 2.引入ContactView.js文件 var ContactView = function() {}; ContactView.prototype.show = function(successCallback, failCallback) { function success(args) { successCallback(args); } function fail(args) { failCallback(args); } return cordova.exec(function(args) { success(args); }, function(args) { fail(args); }, 'ContactView', '', []); }; cordova.addConstructor(function() { cordova.addPlugin('contactView', new ContactView()); PluginManager.addService("ContactView","com.tricedesigns.ContactView"); }); 3.修改plugins.xml 添加标签: <plugin name="ContactView" value="com.tricedesigns.ContactView"/> 4.调用方法: function ccc(){ window.plugins.contactView.show( function(contact) { alert(contact.name+"|"+contact.phone); //document.getElementById("contact-name-from-native").value = contact.name; //document.getElementById("contact-phone").value = contact.phone; }, function(fail) { alert("We were unable to get the contact you selected."); } ); } 5.大功告成~~ 如图:   点击彩铃后:

andriod, phonegap

解决eclipse或motodev 出现adb server is out of date情况(豌豆荚更新引起)

25. 七月 2012
1.首先请确认是否有更新过豌豆荚至2。如果有的话,建议卸载,重新下载一个低版本的。 下载地址:http://www.wandoujia.com/ 2.如果是motodev不要觉得是adt没有升级到20的问题,因为motodev4只能用adt18.0 moto的人已经说了: you should not update the SDK tools or attempt to manually install ADT 20 into MOTODEV Studio. 参考文章: 1.http://community.developer.motorola.com/t5/MOTODEV-Studio-for-Android/MOTODEV-Studio-4-0-and-the-ADT-20-plugins/td-p/27722 2.http://community.developer.motorola.com/t5/MOTODEV-Studio-for-Android-Blog/MOTODEV-Studio-4-0-and-the-ADT-20-plugins/ba-p/27710   3.如果上面的都不行,再试试网上别人给的办法: http://bbs.hiapk.com/thread-2812927-1-1.html http://bbs.mumayi.com/thread-334171-1-1.html

andriod

phonegap(安卓)调用蓝牙及检测蓝牙功能

24. 七月 2012
  Phonegap Andriod 交流 QQ 群 250395324欢迎您的加入   项目代码可去我的qq群共享下载250395324 phonegap蓝牙功能可以让我们判断蓝牙的开启状态、打开、关闭、匹配设备等 我们要做的只是加入.java和.js文件(插件包了提供了一个index.html的页面) 记得添加xml <plugin name="BluetoothPlugin" value="com.tricedesigns.BluetoothPlugin"/> 效果如下:

andriod, phonegap

Phonegap(安卓)实现扫描验证码及生成验证码的功能

23. 七月 2012
项目源代码可去我的qq群共享下载:250395324 插件可以去这里下载:https://github.com/phonegap/phonegap-plugins/ BarcodeScanner 1.添加一个项目,路径:File -> New Android Project -> create project,添加一个已有的项目。 Add the 'LibraryProject' into Eclipse. File -> New Android Project -> create project from existing source. 2.In the new project you've just added to Eclipse go to the project properties. Select the Android section and at the bottom of the dialog check the "Is Library" checkbox. 3.In your application go into the project properties. In the Android section under library click the Add button and select the library you created in step 2. 4.To install the plugin, move barcodescanner.js to your project's www folder and include a reference to it in your html files. 5.添加BarcodeScanner.java文件 6.<plugin name="BarcodeScanner" value="com.phonegap.plugins.barcodescanner.BarcodeScanner"/> 记得改你的package名字。 7.Add the following activity to your AndroidManifest.xml file. It should be added inside the &lt;application/&gt; tag.   Add the following activity to your AndroidManifest.xml file. It should be added inside the <application/> tag. <!-- ZXing activities --> <activity android:name="com.google.zxing.client.android.CaptureActivity" android:screenOrientation="landscape" android:configChanges="orientation|keyboardHidden" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:windowSoftInputMode="stateAlwaysHidden"> <intent-filter> <action android:name="com.phonegap.plugins.barcodescanner.SCAN"/> <category android:name="android.intent.category.DEFAULT"/> </intent-filter> </activity> <activity android:name="com.google.zxing.client.android.encode.EncodeActivity" android:label="@string/share_name"> <intent-filter> <action android:name="com.phonegap.plugins.barcodescanner.ENCODE"/> <category android:name="android.intent.category.DEFAULT"/> </intent-filter> </activity>`       9. And make sure you have the following permission in your AndroidManifest.xml file:     <uses-permission android:name="android.permission.CAMERA" />     10.调用方法:scan   window.plugins.barcodeScanner.scan( function(result) { alert("We got a barcode\n" + "Result: " + result.text + "\n" + "Format: " + result.format + "\n" + "Cancelled: " + result.cancelled); }, function(error) { alert("Scanning failed: " + error); } );     encode方法:   window.plugins.barcodeScanner.encode(BarcodeScanner.Encode.TEXT_TYPE, "http://www.nytimes.com", function(success) { alert("encode success: " + success); }, function(fail) { alert("encoding failed: " + fail); } );  

andriod, phonegap

Andriod客户端如何接受Rest Wcf的数据

20. 七月 2012
  Phonegap Andriod 交流 QQ 群 250395324欢迎您的加入   安卓客户端连接wcf,研究了一天,以前一直觉得不太可能,一个是java的,另外一个是微软的产品,不太容易吧,结果发现用httpclient其实是可以request到wcf传过来的json数据的,绝倒哈哈,对于。net开发转安卓绝对是一大福音哦~~~ 下面来介绍一下连接方式 wcf这块在下就省略了,用的是rest wcf github上就有,大家可以下一个就行   安卓客户端lz的做法是这样的: 首先定义一个按钮,按钮监听事件用httpclient的方法向wcf发送请求(以lz自己的wcf为例) 代码如下:   mbtnStarServ.setOnClickListener( new Button.OnClickListener() { @Override public void onClick( View v ) { //starText.setText( "Hi , Google Android!" ); String httpUrl="http://diamondwcf.cfxixi.com/EmiteDataService.svc/GetDiamondPrice?weigh=1.00"; HttpGet httpRequest=new HttpGet(httpUrl); httpRequest.addHeader("charset", HTTP.UTF_8); httpRequest.setHeader("Accept", "application/json"); httpRequest.addHeader("Content-Type", "application/json"); try { HttpClient httpclient=new DefaultHttpClient(); HttpResponse httpReponse=httpclient.execute(httpRequest); if(httpReponse.getStatusLine().getStatusCode()==HttpStatus.SC_OK) { String strResult=EntityUtils.toString(httpReponse.getEntity()); starText.setText(strResult); } else { starText.setText("请求错误"); } } catch(ClientProtocolException e) { starText.setText(e.getMessage().toString()); } catch(IOException e) { starText.setText(e.getMessage().toString()); } catch(Exception e) { starText.setText(e.getMessage().toString()); } } } );     如此便可返回一串json数据,然后用java的方法去解析 最后如果你遇到了permission deny的情况,记得配置xml中的权限 http://stackoverflow.com/questions/3932129/permission-denied-error-while-call-webservice-using-http-in-android-application <uses-permission android:name="android.permission.INTERNET"></uses-permission> 项目代码可取我的qq群共享下载   Phonegap Andriod 交流 QQ 群 250395324欢迎您的加入   效果如下:

andriod

安卓报错:com.google.android.gsf package couldn't be found

18. 七月 2012
Phonegap Andriod 交流 QQ 群 250395324欢迎您的加入 原文:http://stackoverflow.com/questions/11339445/com-google-android-gsf-package-couldnt-be-found 可能的原因:必须是支持Google APIs.的模拟器才能运行该程序 参考: it seems to me like you're using the wrong emulator. The default emulator uses a regular Android emulator that doesn't have any Google packages and can't run all sorts of things like maps, c2dm and all sorts of stuff like that. what you want to do, is create a new emulator that can support the Google APIs. then, when you run the project, choose the emulator that runs the target name Google APIs (Google Inc). good luck.

andriod

Phonegap中如何打开一个子游览器窗口

18. 七月 2012
  Phonegap Andriod 交流 QQ 群 250395324欢迎您的加入   今天上海早晨下了场雨,天气很舒服,话说今天的探索有hit,不但知道了st中的localstorage方法可以存储个字段,而且还发现了phonegap中可以打开一个子窗口,为日后的微博登录打下了基础。 好了下面来介绍一下这一phonegap插件: 1.首先引入.java文件   /* * PhoneGap is available under *either* the terms of the modified BSD license *or* the * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text. * * Copyright (c) 2005-2011, Nitobi Software Inc. * Copyright (c) 2010-2011, IBM Corporation */ package com.tricedesigns; import java.io.IOException; import java.io.InputStream; import org.apache.cordova.api.Plugin; import org.apache.cordova.api.PluginResult; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.R; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.net.Uri; import android.text.InputType; import android.util.Log; import android.util.TypedValue; import android.view.Gravity; import android.view.KeyEvent; import android.view.View; import android.view.Window; import android.view.WindowManager; import android.view.WindowManager.LayoutParams; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.EditText; import android.widget.ImageButton; import android.widget.LinearLayout; import android.widget.RelativeLayout; public class ChildBrowser extends Plugin { protected static final String LOG_TAG = "ChildBrowser"; private static int CLOSE_EVENT = 0; private static int LOCATION_CHANGED_EVENT = 1; private String browserCallbackId = null; private Dialog dialog; private WebView webview; private EditText edittext; private boolean showLocationBar = true; /** * Executes the request and returns PluginResult. * * @param action The action to execute. * @param args JSONArry of arguments for the plugin. * @param callbackId The callback id used when calling back into JavaScript. * @return A PluginResult object with a status and message. */ public PluginResult execute(String action, JSONArray args, String callbackId) { PluginResult.Status status = PluginResult.Status.OK; String result = ""; try { if (action.equals("showWebPage")) { this.browserCallbackId = callbackId; // If the ChildBrowser is already open then throw an error if (dialog != null && dialog.isShowing()) { return new PluginResult(PluginResult.Status.ERROR, "ChildBrowser is already open"); } result = this.showWebPage(args.getString(0), args.optJSONObject(1)); if (result.length() > 0) { status = PluginResult.Status.ERROR; return new PluginResult(status, result); } else { PluginResult pluginResult = new PluginResult(status, result); pluginResult.setKeepCallback(true); return pluginResult; } } else if (action.equals("close")) { closeDialog(); JSONObject obj = new JSONObject(); obj.put("type", CLOSE_EVENT); PluginResult pluginResult = new PluginResult(status, obj); pluginResult.setKeepCallback(false); return pluginResult; } else if (action.equals("openExternal")) { result = this.openExternal(args.getString(0), args.optBoolean(1)); if (result.length() > 0) { status = PluginResult.Status.ERROR; } } else { status = PluginResult.Status.INVALID_ACTION; } return new PluginResult(status, result); } catch (JSONException e) { return new PluginResult(PluginResult.Status.JSON_EXCEPTION); } } /** * Display a new browser with the specified URL. * * @param url The url to load. * @param usePhoneGap Load url in PhoneGap webview * @return "" if ok, or error message. */ public String openExternal(String url, boolean usePhoneGap) { try { Intent intent = null; if (usePhoneGap) { intent = new Intent().setClass(this.ctx.getContext(), org.apache.cordova.DroidGap.class); intent.setData(Uri.parse(url)); // This line will be removed in future. intent.putExtra("url", url); // Timeout parameter: 60 sec max - May be less if http device timeout is less. intent.putExtra("loadUrlTimeoutValue", 60000); // These parameters can be configured if you want to show the loading dialog intent.putExtra("loadingDialog", "Wait,Loading web page..."); // show loading dialog intent.putExtra("hideLoadingDialogOnPageLoad", true); // hide it once page has completely loaded } else { intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); } this.ctx.startActivity(intent); return ""; } catch (android.content.ActivityNotFoundException e) { Log.d(LOG_TAG, "ChildBrowser: Error loading url "+url+":"+ e.toString()); return e.toString(); } } /** * Closes the dialog */ private void closeDialog() { if (dialog != null) { dialog.dismiss(); } } /** * Checks to see if it is possible to go back one page in history, then does so. */ private void goBack() { if (this.webview.canGoBack()) { this.webview.goBack(); } } /** * Checks to see if it is possible to go forward one page in history, then does so. */ private void goForward() { if (this.webview.canGoForward()) { this.webview.goForward(); } } /** * Navigate to the new page * * @param url to load */ private void navigate(String url) { InputMethodManager imm = (InputMethodManager)this.ctx.getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(edittext.getWindowToken(), 0); if (!url.startsWith("http") && !url.startsWith("file:")) { this.webview.loadUrl("http://" + url); } else { this.webview.loadUrl(url); } this.webview.requestFocus(); } /** * Should we show the location bar? * * @return boolean */ private boolean getShowLocationBar() { return this.showLocationBar; } /** * Display a new browser with the specified URL. * * @param url The url to load. * @param jsonObject */ public String showWebPage(final String url, JSONObject options) { // Determine if we should hide the location bar. if (options != null) { showLocationBar = options.optBoolean("showLocationBar", true); } // Create dialog in new thread Runnable runnable = new Runnable() { /** * Convert our DIP units to Pixels * * @return int */ private int dpToPixels(int dipValue) { int value = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, (float) dipValue, ctx.getContext().getResources().getDisplayMetrics() ); return value; } public void run() { // Let's create the main dialog dialog = new Dialog(ctx.getContext(), android.R.style.Theme_NoTitleBar); dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog; dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCancelable(true); dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { public void onDismiss(DialogInterface dialog) { try { JSONObject obj = new JSONObject(); obj.put("type", CLOSE_EVENT); sendUpdate(obj, false); } catch (JSONException e) { Log.d(LOG_TAG, "Should never happen"); } } }); // Main container layout LinearLayout main = new LinearLayout(ctx.getContext()); main.setOrientation(LinearLayout.VERTICAL); // Toolbar layout RelativeLayout toolbar = new RelativeLayout(ctx.getContext()); toolbar.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, this.dpToPixels(44))); toolbar.setPadding(this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2)); toolbar.setHorizontalGravity(Gravity.LEFT); toolbar.setVerticalGravity(Gravity.TOP); // Action Button Container layout RelativeLayout actionButtonContainer = new RelativeLayout(ctx.getContext()); actionButtonContainer.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); actionButtonContainer.setHorizontalGravity(Gravity.LEFT); actionButtonContainer.setVerticalGravity(Gravity.CENTER_VERTICAL); actionButtonContainer.setId(1); // Back button ImageButton back = new ImageButton(ctx.getContext()); RelativeLayout.LayoutParams backLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT); backLayoutParams.addRule(RelativeLayout.ALIGN_LEFT); back.setLayoutParams(backLayoutParams); back.setContentDescription("Back Button"); back.setId(2); try { back.setImageBitmap(loadDrawable("www/childbrowser/icon_arrow_left.png")); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } back.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goBack(); } }); // Forward button ImageButton forward = new ImageButton(ctx.getContext()); RelativeLayout.LayoutParams forwardLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT); forwardLayoutParams.addRule(RelativeLayout.RIGHT_OF, 2); forward.setLayoutParams(forwardLayoutParams); forward.setContentDescription("Forward Button"); forward.setId(3); try { forward.setImageBitmap(loadDrawable("www/childbrowser/icon_arrow_right.png")); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } forward.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goForward(); } }); // Edit Text Box edittext = new EditText(ctx.getContext()); RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); textLayoutParams.addRule(RelativeLayout.RIGHT_OF, 1); textLayoutParams.addRule(RelativeLayout.LEFT_OF, 5); edittext.setLayoutParams(textLayoutParams); edittext.setId(4); edittext.setSingleLine(true); edittext.setText(url); edittext.setInputType(InputType.TYPE_TEXT_VARIATION_URI); edittext.setImeOptions(EditorInfo.IME_ACTION_GO); edittext.setInputType(InputType.TYPE_NULL); // Will not except input... Makes the text NON-EDITABLE edittext.setOnKeyListener(new View.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { navigate(edittext.getText().toString()); return true; } return false; } }); // Close button ImageButton close = new ImageButton(ctx.getContext()); RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT); closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); close.setLayoutParams(closeLayoutParams); forward.setContentDescription("Close Button"); close.setId(5); try { close.setImageBitmap(loadDrawable("www/childbrowser/icon_close.png")); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } close.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { closeDialog(); } }); // WebView webview = new WebView(ctx.getContext()); webview.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); webview.setWebChromeClient(new WebChromeClient()); WebViewClient client = new ChildBrowserClient(edittext); webview.setWebViewClient(client); WebSettings settings = webview.getSettings(); settings.setJavaScriptEnabled(true); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setBuiltInZoomControls(true); settings.setPluginsEnabled(true); settings.setDomStorageEnabled(true); webview.loadUrl(url); webview.setId(6); webview.getSettings().setLoadWithOverviewMode(true); webview.getSettings().setUseWideViewPort(true); webview.requestFocus(); webview.requestFocusFromTouch(); // Add the back and forward buttons to our action button container layout actionButtonContainer.addView(back); actionButtonContainer.addView(forward); // Add the views to our toolbar toolbar.addView(actionButtonContainer); toolbar.addView(edittext); toolbar.addView(close); // Don't add the toolbar if its been disabled if (getShowLocationBar()) { // Add our toolbar to our main view/layout main.addView(toolbar); } // Add our webview to our main view/layout main.addView(webview); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.FILL_PARENT; lp.height = WindowManager.LayoutParams.FILL_PARENT; dialog.setContentView(main); dialog.show(); dialog.getWindow().setAttributes(lp); } private Bitmap loadDrawable(String filename) throws java.io.IOException { InputStream input = ctx.getAssets().open(filename); return BitmapFactory.decodeStream(input); } }; this.ctx.runOnUiThread(runnable); return ""; } /** * Create a new plugin result and send it back to JavaScript * * @param obj a JSONObject contain event payload information */ private void sendUpdate(JSONObject obj, boolean keepCallback) { if (this.browserCallbackId != null) { PluginResult result = new PluginResult(PluginResult.Status.OK, obj); result.setKeepCallback(keepCallback); this.success(result, this.browserCallbackId); } } /** * The webview client receives notifications about appView */ public class ChildBrowserClient extends WebViewClient { EditText edittext; /** * Constructor. * * @param mContext * @param edittext */ public ChildBrowserClient(EditText mEditText) { this.edittext = mEditText; } /** * Notify the host application that a page has started loading. * * @param view The webview initiating the callback. * @param url The url of the page. */ @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { super.onPageStarted(view, url, favicon); String newloc; if (url.startsWith("http:") || url.startsWith("https:") || url.startsWith("file:")) { newloc = url; } else { newloc = "http://" + url; } if (!newloc.equals(edittext.getText().toString())) { edittext.setText(newloc); } try { JSONObject obj = new JSONObject(); obj.put("type", LOCATION_CHANGED_EVENT); obj.put("location", url); sendUpdate(obj, true); } catch (JSONException e) { Log.d("ChildBrowser", "This should never happen"); } } } }     2.引入.js文件   /* * cordova is available under *either* the terms of the modified BSD license *or* the * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text. * * Copyright (c) 2005-2010, Nitobi Software Inc. * Copyright (c) 2011, IBM Corporation */ /** * Constructor */ function ChildBrowser() { }; ChildBrowser.CLOSE_EVENT = 0; ChildBrowser.LOCATION_CHANGED_EVENT = 1; /** * Display a new browser with the specified URL. * This method loads up a new web view in a dialog. * * @param url The url to load * @param options An object that specifies additional options */ ChildBrowser.prototype.showWebPage = function(url, options) { alert("enter"); if (options === null || options === "undefined") { var options = new Object(); options.showLocationBar = true; } cordova.exec(this._onEvent, this._onError, "ChildBrowser", "showWebPage", [url, options]); }; /** * Close the browser opened by showWebPage. */ ChildBrowser.prototype.close = function() { cordova.exec(null, null, "ChildBrowser", "close", []); }; /** * Display a new browser with the specified URL. * This method starts a new web browser activity. * * @param url The url to load * @param usecordova Load url in cordova webview [optional] */ ChildBrowser.prototype.openExternal = function(url, usecordova) { if (usecordova === true) { navigator.app.loadUrl(url); } else { cordova.exec(null, null, "ChildBrowser", "openExternal", [url, usecordova]); } }; /** * Method called when the child browser has an event. */ ChildBrowser.prototype._onEvent = function(data) { if (data.type == ChildBrowser.CLOSE_EVENT && typeof window.plugins.childBrowser.onClose === "function") { window.plugins.childBrowser.onClose(); } if (data.type == ChildBrowser.LOCATION_CHANGED_EVENT && typeof window.plugins.childBrowser.onLocationChange === "function") { window.plugins.childBrowser.onLocationChange(data.location); } }; /** * Method called when the child browser has an error. */ ChildBrowser.prototype._onError = function(data) { if (typeof window.plugins.childBrowser.onError === "function") { window.plugins.childBrowser.onError(data); } }; /** * Maintain API consistency with iOS */ ChildBrowser.install = function(){ return window.plugins.childBrowser; }; /** * Load ChildBrowser */ cordova.addConstructor(function() { cordova.addPlugin("childBrowser", new ChildBrowser()); });   3.在plugin.xml中定义tag   <plugin name="ChildBrowser" value="com.tricedesigns.ChildBrowser"/>   4.定义调用的js方法   function bbb(){ window.plugins.childBrowser.showWebPage("https://api.weibo.com/2/oauth2/authorize?client_id=1996979548&response_type=token&display=js&redirect_uri=https://api.weibo.com/oauth2/xd.html", { showLocationBar: true }); }   5.ok,run 源代码可去我的qq群中下载:250395324

andriod, phonegap

解决安卓sdk ADT版本不够问题 Android SDK requires android developer toolkit version 17.0.0 or above

26. 六月 2012
原文:http://stackoverflow.com/questions/10074532/android-sdk-requires-android-developer-toolkit-version-17-0-0-or-above Run software updates in Eclipse (Help > Check for Updates) and update the ADT.

andriod

安卓app应用市场

24. 四月 2012
  http://apk.hiapk.com/  安卓市场 nc您的软件发现功能以外的涉及用户隐私的“读取联系人数据”权限 被拒   http://bbs.anzhi.com 安智市场   http://dev.appchina.com app应用汇   http://developer.lenovomm.com 乐商店   http://www.mumayi.com/ 木蚂蚁   http://www.apkdd.com/ 安卓地带   Dev.3g.cn 3g发布

andriod

安卓读条形码

20. 四月 2012
参考一:http://blog.csdn.net/hellogv/article/details/6101663 参考二:http://apps.hi.baidu.com/share/detail/30046305 参考三:http://hi.baidu.com/09july/blog/item/50853e109aca4c0db9127be1.html  

andriod

安卓判断设备类型

18. 四月 2012
原文:http://www.pslib.com/index.php?mod=skill&action=detail&id=44033 lz网上找了一下发现,发现直接判断的api貌似没有,没办法,搜索了一下主流的方法还是判断屏幕分辨率的 5)获取设备屏幕分辨率    首先我们需要用到的是DisplayMetrics这个类,它可以为我们获得手机屏幕属性,这里将其所在类导入。    import android.util.DisplayMetrics;    得到实例对象。    DisplayMetrics dm = new DisplayMetrics();      getWindowManager().getDefaultDisplay().getMetrics(dm);    得到手机屏幕高度:    dm.heightPixels;    得到手机屏幕宽度:    dm.widthPixels;    得到以上手机屏幕的高度跟宽度后,即可以通过这两个值按照比例还设定程序布局中空间的大小。   大家有发现api的话记得通知lz。

andriod

phonegap+andriod+sencha开发注意

17. 四月 2012
  主要是phonegap的用法,sencha比较简单,首先第一步我们根据教程在spring source(java ide)中根据教程创建项目。 参考:http://www.phonegap.cn/?page_id=442#android   需要嵌入phonegap代码时希望大家能够注意:   <script type="text/javascript" charset="utf-8"> // 等待加载PhoneGap document.addEventListener(“deviceready“, onDeviceReady, false); // PhoneGap加载完毕,可以安全调用PhoneGap方法 function onDeviceReady() { checkConnection(); } function checkConnection() { var networkState = navigator.network.connection.type; var states = {}; states[Connection.UNKNOWN] = 'Unknown connection'; states[Connection.ETHERNET] = 'Ethernet connection'; states[Connection.WIFI] = 'WiFi connection'; states[Connection.CELL_2G] = 'Cell 2G connection'; states[Connection.CELL_3G] = 'Cell 3G connection'; states[Connection.CELL_4G] = 'Cell 4G connection'; states[Connection.NONE] = 'No network connection'; alert('Connection type: ' + states[networkState]); }   像这样在phonegap文件完全载入后(deviceready函数完成后填入代码)。 此外lz使用的是phonegap1.0的js,1.6的js不知为什么无法识别lz的手机。。。。。。如有类似情况,大家一起交流,呵呵   最新标准调用phonegap方法 <script type="text/javascript">   document.addEventListener("deviceready", mainLaunch, false); </script> 然后在你的JS里面这样写   function mainLaunch(){ Ext.application({   就可以了

andriod, phonegap, sencha-touch1.1

andriod真机调试

13. 四月 2012
原文:http://blog.csdn.net/richway2010/article/details/6640837 装不上驱动的可以下载“豌豆荚”,会自动搜索驱动的。 Android如何运行真机在eclipse上调试应用?   主要通过以下几个步骤:   1、手机通过数据线连接在电脑上 2、设置android手机为USB调试模式。步骤: menu—> 设置 —> 应用程序 —> 开发 , 选择【USB调试】 3、如果是window系统,系统会提示安装驱动:   选择正确的android sdk安装目录,然后点击下一步,系统就开始安装驱动了 4、驱动安装完成之后,重启电脑(通常系统会有“安装新驱动,重启才能生效”的提示),这但应该明白吧 5、重复第1步和第2步,打开命令窗口,检测手机设备是否已经被识别,如下所示:   “HT99YLG11834 device”就是检测到得手机设备 6、接下来就开始在eclipse上调试android程序了,右击android工程->Run as->Android Application,弹出如下窗口:(重新启动系统之后才有这样的效果)   7、选中手机设备,点击OK之后,程序就开始在真机上安装了,控制台输出如下信息: [2011-04-07 22:24:49 - HelloWorld] Uploading HelloWorld.apk onto device ‘HT99YLG11834′[2011-04-07 22:24:49 - HelloWorld] Installing HelloWorld.apk…[2011-04-07 22:24:53 - HelloWorld] Success![2011-04-07 22:24:53 - HelloWorld] Starting activity com.eightqiu.activity.StatsResultActivity on device[2011-04-07 22:24:57 - HelloWorld] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.eightqiu.activity/.StatsResultActivity }   8. 设置应用程序为调试模式。操作: 编辑AndroidManifest.xml 增加调试参数android:debuggable="true", 如下: <application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true"> 9. 执行真机调试操作:ECLIPSE调试对话框中,Target窗口中选择Manual,点击【debug】按钮,选择真机设备,开始调试。  注:不管是否启用ECLIPSE环境,任何Android软件只要在真机上运行发生异常,都可以在命令行窗口下查看具体异常信息:  执行:./adb logcat 可以查看到更多的系统异常消息。在这些消息中要注意查看Caused by:打 头的行,这些行指明了在哪行代码出的错误 10、运行这个应用程序,这样就可以使用手机来测试了   装不上驱动的可以下载“豌豆荚”,会自动搜索驱动的。  

andriod

andriod读取imsi码(设计构想)

12. 四月 2012
  1、给phonegap写一个可以获取imsi码的插件 2、用js调用phonegap插件读取imsi码,将web app用phonegap打包 3、第一次运行时要求用户提交自己的手机号码,从而将手机号码与imsi进行关联并保存在服务器 4、再次运行时首先读取imsi,然后提交到服务器查询得知手机号码 5、检查手机号码在服务端是否为登录状态,如果是,客户端直接跳转进入主界面

andriod, phonegap

给使用phonegap的Android程序加上splash screen(启动图片 预览图))

12. 四月 2012
  http://bbs.phonegapcn.com/thread-49-1-1.html   1. 开始画面其实很好解决的啊,原生态是一种(连接的方法)2.另外一种在body的onload事件里面解决也行啊先加载一个图片,全屏,延时加载APP的JS 

andriod

The connection to the server was unsuccessful.(file:///android_asset/www/index.html)

12. 四月 2012
  原文:http://stackoverflow.com/questions/7633940/the-connection-to-the-server-was-unsuccessful-file-android-asset-www-index-h   question:  i am developing a android app using phonegap, it calls a website (http://siteaddress.com:8081) to get json encoded data. This is working fine on the emulator, then I built the android package .apk file using phonegap build but when i installed this package on my android phone and started the app, it force closes the application showing the error "The connection to the server was unsuccessful.(file:///android_asset/www/index.html)". I have built the app using phonegap build, passed it the index.html as well as tried the .zip file package but still getting this error. I tried searching for this error and also included the below code in my app as suggested on some sites but still it is giving error. super.setBooleanProperty("loadInWebView", true);super.setIntegerProperty("loadUrlTimeoutValue", 60000); Has this got something to do with the website that i am trying to call from my app? I tried opening that site in the mobile browser but it didn't opened but the website works fine on a desktop browser. Is there something wrong that i am doing?     answer:I'm guessing its the port number your using. Have you tried using port 80 for your server rather than 8081? Its possible that port isn't open on your device.

phonegap, andriod