`
sharp2wing
  • 浏览: 267575 次
  • 性别: Icon_minigender_1
  • 来自: 南京
文章分类
社区版块
存档分类
最新评论
阅读更多
android中如何改变AudioButton的显示图片 :

android:button="@drawable/search_btn_radio"



android中调用Google Search: 



Intent search = new Intent(Intent.ACTION_WEB_SEARCH);
search.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
search.putExtra(SearchManager.QUERY, "eoeAndroid");
final Bundle appData = getIntent().getBundleExtra(SearchManager.APP_DATA);
if (appData != null) {
      search.putExtra(SearchManager.APP_DATA, appData);


startActivity(search);






android 打开本地html文件:

Intent intent=new Intent();
intent.setAction("android.intent.action.VIEW");

Uri CONTENT_URI_BROWSERS = Uri.parse("content://com.android.htmlfileprovider/sdcard/123.html");
           
intent.setData(CONTENT_URI_BROWSERS);
intent.setClassName("com.android.browser", "com.android.browser.BrowserActivity");

startActivity(intent);

假设要打开的本地html文件存放在如下路径
/sdcard/123.html



android 打开本地文件:

Intent in3 = new Intent();
in3.setAction("android.intent.action.VIEW");
Uri uri3 = Uri.parse("file://"+searchInfo.absolutePath);
in3.setDataAndType(uri3, "video/*");
startActivity(in3);

android打开其他程序Activity:



Uri uri = Uri.parse("package:system.app.Mms");

Intent intent = new Intent(Intent.ACTION_MAIN);

intent.addCategory(Intent.CATEGORY_LAUNCHER);

//这里的className里的信息都可以从eclipse测logcat里面得到

intent.setClassName("com.android.mms", "com.androis.mms.ui.ConversationList");

mLauncher.startActivity(intent);





查询短信数据库:

String strUriInbox = "content://sms";
Uri uriSms = Uri.parse(strUriInbox);
Cursor c_groups = managedQuery( uriSms , new String[] { "date","person" }, select, null, "date DESC");

strColumnName=_id                strColumnValue=48                  //短消息序号 
strColumnName=thread_id          strColumnValue=16                  //对话的序号(conversation)
strColumnName=address            strColumnValue=+8613411884805      //发件人地址,手机号
strColumnName=person              strColumnValue=null                //发件人,返回一个数字就是联系人列表里的序号,陌生人为null
strColumnName=date                strColumnValue=1256539465022        //日期  long型,想得到具体日期自己转换吧!
strColumnName=protocol            strColumnValue=0                    //协议
strColumnName=read                strColumnValue=1                    //是否阅读
strColumnName=status              strColumnValue=-1                  //状态
strColumnName=type                strColumnValue=1                    //类型 1是接收到的,2是发出的
strColumnName=reply_path_present  strColumnValue=0                    //
strColumnName=subject            strColumnValue=null                //主题
strColumnName=body                strColumnValue=您好                                                      //短消息内容
strColumnName=service_center      strColumnValue=+8613800755500      //短信服务中心号码编号,可以得知该短信是从哪里发过来的见下表

2.联系人数据库

strColumnName = _sync_id  strColumnValue=null
strColumnName = primary_organization  strColumnValue=null
strColumnName = notes  strColumnValue=null
strColumnName = primary_phone  strColumnValue=1
strColumnName = status  strColumnValue=null
strColumnName = im_handle  strColumnValue=null
strColumnName = _sync_local_id  strColumnValue=null
strColumnName = im_account  strColumnValue=null
strColumnName = _sync_time  strColumnValue=null
strColumnName = im_protocol  strColumnValue=null
strColumnName = mode  strColumnValue=null
strColumnName = label  strColumnValue=null
strColumnName = times_contacted  strColumnValue=0
strColumnName = name  strColumnValue=é??è?3
strColumnName = send_to_voicemail  strColumnValue=null
strColumnName = primary_email  strColumnValue=null
strColumnName = custom_ringtone  strColumnValue=null
strColumnName = sort_string  strColumnValue=í?¤í2?í??ío3à?
strColumnName = _sync_version  strColumnValue=null
strColumnName = last_time_contacted  strColumnValue=null
strColumnName = _sync_account  strColumnValue=null
strColumnName = display_name  strColumnValue=é??è?3
strColumnName = number_key  strColumnValue=77681111831
strColumnName = number  strColumnValue=13811118677
strColumnName = phonetic_name  strColumnValue=null
strColumnName = _id  strColumnValue=1
strColumnName = type  strColumnValue=2
strColumnName = _sync_dirty  strColumnValue=1
strColumnName = starred  strColumnValue=0
4.其他数据库
//Available Uri string
content://contacts/people    //本地联系人列表信息
content://contacts/phones    //本地联系人列表信息
content://call_log/calls/    //本地通话记录       

content://mms            彩信
content://mms-sms/threadID
content://mms-sms/conversations
content://mms-sms/messages/byphone
content://mms-sms/undelivered
content://mms-sms/draft


String strUriInbox        = "content://sms/inbox";        //SMS_INBOX:1
String strUriFailed      = "content://sms/failed";      //SMS_FAILED:2
String strUriQueued      = "content://sms/queued";      //SMS_QUEUED:3
String strUriSent        = "content://sms/sent";        //SMS_SENT:4
String strUriDraft        = "content://sms/draft";        //SMS_DRAFT:5
String strUriOutbox      = "content://sms/outbox";      //SMS_OUTBOX:6
String strUriUndelivered  = "content://sms/undelivered";  //SMS_UNDELIVERED
String strUriAll          = "content://sms/all";          //SMS_ALL
String strUriConversations= "content://sms/conversations";//you can delete one conversation by thread_id
String strUriAll          = "content://sms"              //you can delete one message by _id

Android SmsManager 开机短信自动发送

SmsManager短信的发送代码:
SmsManager sms = SmsManager.getDefault();
String SENT = "SMS_SENT";
String DELIVERED = "SMS_DELIVERED";
PendingIntent sentPI = PendingIntent.getBroadcast(this, 0,new Intent(SENT), 0);
PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0,new Intent(DELIVERED), 0);
sms.sendTextMessage("10086", null, "cxyl", sentPI, deliveredPI);
Toast.makeText(this, "ok", Toast.LENGTH_LONG).show();


我们用到了sendTextMessage函数,在sdk中
public void sendTextMessage (String destinationAddress, String scAddress, String text, PendingIntent sentIntent, PendingIntent deliveryIntent)
destinationAddress:  收件人地址
scAddress:  短信中心号码,空为默认中心号码
sentIntent: 当消息发出时,成功或者失败的信息报告通过PendingIntent来广播。如果该参数为空,则发信程序会被所有位置程序检查一遍,这样会导致发送时间延长。
deliveryIntent: 当消息发送到收件人时,该PendingIntent会被广播。pdu数据在状态报告的extended data (“pdu”)中。
抛出 IllegalArgumentException  如果收件人或者信息为空。
public static PendingIntent getBroadcast (Context context, int requestCode, Intent intent, int flags)
返回一个用于广播的PendingIntent,类似于调用Context.sendBroadcast()函数
requestCode 暂时不用
intent 是用于广播的intent
flag 有:FLAG_ONE_SHOT, FLAG_NO_CREATE, FLAG_CANCEL_CURRENT, FLAG_UPDATE_CURRENT 用于设置新建的PendingIntent是使用一次、如无则不创建、取消当前、更新当前等属性。

1.Android SDK应该从什么地方下载?为什么(http://developer.Android.com/  )经常上不上去?

答:谷歌官网的 (http://developer.Android.com/ ) 这个被和谐了,经常上不去,中国的网络大家都是 知道的呵呵~

    下载SDK,我给大家推荐下面网站比较及时,和谷歌同步的!网址:( http://androidappdocs.appspot.com/ ).

2.drawable-hdpi,drawable-ldpi,drawable-mdpi有什么区别?

答:主要是为了支持多分辨率的.
hdpi里面主要放高分辨率的图片,如WVGA (480x800),FWVGA (480x854)
mdpi 里面主要放中等分辨率的图片,如HVGA (320x480)
ldpi里面主要放低分辨率的图片,如QVGA (240x320)
系统会根据机器的分辨率来分别到这几个文件夹里面去找对应的图片
所以在开发程序时为了兼容不同平台不同屏幕,建议各自文件夹根据需求均存放不同版本图片

3.Android 判断SdCard是否存在?

答:if (android .os.Environment.getExternalStorageState().equals(
android.os.Environment.MEDIA_MOUNTED))

4.Android 删除文件为什么总是报错,删除不了?

答:Android自1.6版本以后,引入了一个权限,让用户可以修改外部存储设备文件,这个问题只要我们在Manifest.xml加一个 permission节点就可以解决了:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

5.Android 如何判断系统语言?



view plaincopy to clipboardprint?
01.private String getLocaleLanguage() { 
02.        Locale l = Locale.getDefault(); 
03.        return String.format("%s-%s", l.getLanguage(), l.getCountry()); 
04.    }
private String getLocaleLanguage() {
  Locale l = Locale.getDefault();
  return String.format("%s-%s", l.getLanguage(), l.getCountry());
}

返回en-US(也可能是en-XX)表示英语,zh-CN表示简体中文,zh-TW表示繁体中文,以此类推。

6.Android 如何判断系统时间是12小时制还是24小时制?

view plaincopy to clipboardprint?
01.ContentResolver cv = this.getContentResolver(); 
02.        String strTimeFormat = android.provider.Settings.System.getString(cv, 
03.                                           android.provider.Settings.System.TIME_12_24);
ContentResolver cv = this.getContentResolver();
         String strTimeFormat = android.provider.Settings.System.getString(cv,
                                            android.provider.Settings.System.TIME_12_24);

返回值strTimeFormat有三种可能一种是NULL,一种是24,另外一种是12.

错误集:

1. UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lorg/xmlpull/v1/XmlPullParser;
....
Conversion to Dalvik format failed with error 1

i solved the problem.

i seems that is have two jars on my buildpath that include the same package and classes.

i used smack.jar and android_maps_lib-1.0.2

delete this package from one jar solved the problem.



4. m访问网络(httppost httpget) 遇到本地pc设置有代理的问题时,依照一般的连接方式有错误

需在模拟器上添加:

System.getProperties().put("proxySet", "true");
System.getProperties().put("proxyHost", proxyIp);
System.getProperties().put("proxyPort", proxyPort);

第一行通知 Java 您要通过代理进行连接,第二行指定代理所在的机器,第三行指定代理监听的端口


5.android 正确获取屏幕像素大小

DisplayMetrics dm = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(dm);
        int widthPixels= dm.widthPixels;
        int heightPixels= dm.heightPixels;
        float density = dm.density;
                int screenWidth = widthPixels * density ;
                int screenHeight = heightPixels * density ;



6. 本地assets目录下的html 文件:web2.loadUrl("file:///android_asset/index.html") ;

InputStreamReader inputReader = new InputStreamReader( getResources().getAssets().open(fileName) );                             

InputStreamReader inputReader = new InputStreamReader(getResources().openRawResource(R.raw.test1));    





7. 检查网络是否可用:
public static boolean chkConnection() {

ConnectivityManager cwjManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
        cwjManager.getActiveNetworkInfo();
        if (cwjManager.getActiveNetworkInfo() != null) {
            return cwjManager.getActiveNetworkInfo().isAvailable();
        }
    return false;
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics