mikebai.com

  • Home
  • dev
  • DotNET
  • M365
  • 搞笑
  • 杂七杂八
  • FocusDict
個人BLOG
it developer
dev

如何选择 compileSdkVersion, minSdkVersion 和 targetSdkVersion

英文原文:Picking your compileSdkVersion, minSdkVersion, and targetSdkVersion 作者:Ian Lake,Google Android 推广工程师;翻译:韩国恺。 当你发布一个应用之后,(取决于具体的发布时间)可能没过几个月 Android 系统就发布了一个新版本。这对你的应用意味着什么,所有东西都不能用了? 别担心,向前兼容是 Android 非常关注的事情。用户在升级到新版 Android 的时候,用以前版本的 SDK 构建的现有应用应该不会出问题。这就是 compileSdkVersion, minSdkVersion 和 targetSdkVersion 的作用:他们分别控制可以使用哪些 API ,要求的 API 级别是什么,以及应用的兼容模式。 compileSdkVersion compileSdkVersion 告诉 Gradle 用哪个 Android SDK 版本编译你的应用。使用任何新添加的 API 就需要使用对应 Level 的 Android SDK。 需要强调的是修改 compileSdkVersion 不会改变运行时的行为。当你修改了 compileSdkVersion 的时候,可能会出现新的编译警告、编译错误,但新的 compileSdkVersion 不会被包含到 APK 中:它纯粹只是在编译的时候使用。(你真的应该修复这些警告,他们的出现一定是有原因的) 因此我们强烈推荐总是使用最新的 SDK 进行编译。在现有代码上使用新的编译检查可以获得很多好处,避免新弃用的 API ,并且为使用新的 API 做好准备。 注意,如果使用 Support Library ,那么使用最新发布的 Support Library 就需要使用最新的 SDK 编译。例如,要使用 23.1.1 版本的 Support Library ,compileSdkVersion 就必需至少是 23 (大版本号要一致!)。通常,新版的 Support Library 随着新的系统版本而发布,它为系统新增加的 API 和新特性提供兼容性支持。 minSdkVersion 如果 compileSdkVersion 设置为可用的最新 API,那么 minSdkVersion 则是应用可以运行的最低要求。minSdkVersion 是 Google Play 商店用来判断用户设备是否可以安装某个应用的标志之一。

2016-11-09 0comments 125hotness 0likes mikebai Read all
DotNET

The Log4net log records to the Oracle 11g

Tried many times, the current Log4net does not support the log to Oracle 11g database, so a variety of search. 1 download the log4net source code is rewritten 1.1 add a reference to Oracle.DataAccess 1.2 add OracleAppender Click here to download Can also click here to download the compiled log4net.dll 2 new Web project, add a reference to the log4net.dll and Oracle.DataAccess.dll, and the Web.config configuration The 2.1 increase in section <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />        The 2.2 increase in log4net configuration <log4net> <appender name="OracleAppender" type="log4net.Appender.OracleAppender"> <bufferSize value="1" /> <connectionType value="Oracle.DataAccess.Client.OracleConnection, Oracle.DataAccess, Version=4.113.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342" /> <connectionString value="DATA SOURCE= database TNSNAME; USER ID= user name PASSWORD= password;"/> <commandText value="INSERT INTO LOG4NET (LOG_ID, LOG_DATE, LOG_LEVEL, LOG_IDENTITY, LOG_MESSAGE, LOG_EXCEPTION, LOG_LOGGER, LOG_SOURCE) VALUES (LOG4NET_SEQ.nextval, :log_date, :log_level, :log_identity, :log_message, :log_exception, :logger, :source)" /> <parameter> <parameterName

2016-07-01 0comments 146hotness 0likes mikebai Read all
DotNET

Create a log4net logger in code

I found myself requiring to instantiate a log4net logger in code (not through the xml configuration). However, there are a few things that I haven’t worked around yet, here’s the code I came up with. var hierarchy = (Hierarchy)LogManager.GetRepository(); var logger = hierarchy.LoggerFactory.CreateLogger((ILoggerRepository)hierarchy, "logname"); logger.Hierarchy = hierarchy;   logger.AddAppender(CreateFileAppender()); logger.AddAppender(CreateDbAppender());   logger.Repository.Configured = true;   // alternative use the LevelMap to set the Log level based on a string // hierarchy.LevelMap["ERROR"] hierarchy.Threshold = Level.Debug; logger.Level = Level.Debug;   ILog log = new LogImpl(logger);   log.Error(“This is my error message”); Note that setting the level needs to be both on the hierarchy and the logger. This is based on the log4net hierarchy implementation. Creating the Appenders is quite simple. private IAppender CreateFileAppender() {     var fileAppender = new RollingFileAppender     {         Name = "myFileAppenderName",         File = "logfile.log",         LockingModel = new FileAppender.MinimalLock(),         AppendToFile = true,         RollingStyle = RollingFileAppender.RollingMode.Size,         MaxSizeRollBackups = 2,         MaximumFileSize = "1MB",         StaticLogFileName = true,         Layout = new log4net.Layout.PatternLayout("%d [%t] %-5p %c %m%n")     };     fileAppender.ActivateOptions();     return fileAppender; }   private IAppender CreateDBAppender() {     RawLayoutConverter layoutConverter = new RawLayoutConverter();       var databaseAppender = new AdoNetAppender     {         Name = "myDbAppender",         ConnectionString = connectionStringBuilder.ConnectionString,         CommandText = @"INSERT INTO [Log] ([DateTime], [Exception], [Level], [Logger], [Message], [Thread])                         VALUES (@logdate, @exception, @level, @logger, @message, @thread)",         CommandType = System.Data.CommandType.Text,         ConnectionType = "System.Data.SqlClient.SqlConnection",         UseTransactions = true     };       databaseAppender.AddParameter(new AdoNetAppenderParameter         {             ParameterName = "@logdate",             DbType = System.Data.DbType.DateTime,             Layout = new…

2016-07-01 0comments 137hotness 0likes mikebai Read all
DotNET

Log4Net を利用してログを記録する

C#.NET で Log4Net を利用してログを記録する設定のメモ。 方針 ログを %Appdata%\[会社名]\[製品名]\log\ の下に保存したい [会社名]=Rohinomiya [製品名]=SampleLog4Net ログを以下のように3つに分けたい インフォログ(1つのファイルに出力/INFO~WARNレベルのログを保存) エラーログ(日付別にファイルを作成/ERROR~FATALのログを保存) トレースログ(日付別にファイルを作成/TRACE~FATALのログを保存) 参考:ログレベル Fatal システム停止するような致命的な障害 Error システム停止はしないが、問題となる障害 Warn 障害ではない注意警告 Info 操作ログなどの情報 Debug 開発用のデバッグメッセージ trace 詳細なデバッグの出力 設定手順 Log4Net公式サイトからLog4Net.dllをダウンロードし、C#プロジェクトの参照設定に追加 AssemblyInfo.cs に追記: Log4Netの設定ファイルを読み込む Log4Netの設定ファイルを記述する(Log4net.Config.xml) 出力フォルダにコピーする=TRUE Program.cs にて、Loggerオブジェクトを生成すれば、あとはログを吐くだけ AssemblyInfo.cs に追記 AssemblyInfo.cs // read Log4Net Configuration file [assembly: log4net.Config.XmlConfigurator(ConfigFile=@"Log4net.Config.xml", Watch=true)] Log4net.Config.xml Log4net.Config.xml <?xml version="1.0" encoding="utf-8" ?> <configuration> <log4net> <!-- 通常ログ:単一ファイル出力 --> <appender name="InfoLogDailyAppender" type="log4net.Appender.FileAppender"> <File value="${APPDATA}\\Rohinomiya\\SampleLog4Net\\Logs\\Info.log" /> <AppendToFile value="true" /> <filter type="log4net.Filter.LevelRangeFilter"> <param name="LevelMax" value="WARN" /> <param name="LevelMin" value="INFO" /> </filter> <layout type="log4net.Layout.PatternLayout"> <ConversionPattern value="%date [%thread] [%-5level] %logger - %message%n" /> </layout> </appender> <!-- エラーログ:分割ファイル出力 --> <appender name="ErrorLogDailyAppender" type="log4net.Appender.RollingFileAppender"> <!-- ファイル名は日付ごと --> <param name="File" value="${APPDATA}\\Rohinomiya\\SampleLog4Net\\Logs\\Error_" /> <pa

2016-07-01 0comments 141hotness 0likes mikebai Read all
DotNET

japanse converter unitity

はじめに Microsoft.VisualBasic.dll は参照したくない。 じゃあどうするか 以下のコードで次のことが可能になります。 C# 特有のこととかはしてないので、どの言語でも使いまわせると思います。 できること 「ひらがな」の判定 「全角カタカナ」の判定 「半角カタカナ」の判定 「漢字」の判定 「ひらがな」から「全角カタカナ」への変換 「ひらがな」から「半角カタカナ」への変換 「全角カタカナ」から「ひらがな」への変換 「全角カタカナ」から「半角カタカナ」への変換 「半角カタカナ」から「ひらがな」への変換 「半角カタカナ」から「全角カタカナ」への変換 濁点や半濁点を前の文字と合成して 1 つの文字に変換 Japanese.cs namespace MMFrame.Text.Language { /// <summary> /// 日本語に関するクラス /// </summary> public class Japanese { /// <summary> /// カタカナのテーブル /// </summary> private static readonly string[] KATAKANA_TABLE = new string[] { "ガ", "ガ", "ギ", "ギ", "グ", "グ", "ゲ", "ゲ", "ゴ", "ゴ", "ザ", "ザ", "ジ", "ジ", "ズ", "ズ", "ゼ", "ゼ", "ゾ", "ゾ", "ダ", "ダ", "ヂ", "ヂ", "ヅ", "ヅ", "デ", "デ", "ド", "ド", "バ", "バ", "ビ", "ビ", "ブ", "ブ", "ベ", "ベ", "ボ", "ボ", "ヴ", "ヴ", "ヷ", "ヷ",

2016-06-06 0comments 154hotness 0likes mikebai Read all
dev

android studio 混淆开启后,发布错误

发布apk时候,出现下面的错误 Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'. > java.io.IOException: Please correct the above warnings first. 解决办法 proguard-rules.pro文件中,加入下面的语句 -keep class com.google.android.gms.** { *; }-dontwarn com.google.android.gms.**

2016-06-05 0comments 116hotness 0likes mikebai Read all
dev

android scollview嵌套webview底部空白,高度无法自适应解决

版权声明:转载请标明出处http://blog.csdn.net/self_study,对技术感兴趣的同鞋加群544645972一起交流 最近要做一个页面,需要scollview嵌套webview,怎么嵌套,怎么解决焦点和touch时间冲突,网上一大堆,这里就不赘述了 但是发现webview从一个高度很高的网页加载一个高度很低的网页的时候,高度无法自适应了,造成底部会有一大片的空白,解决方案找到了挺多,描述一下 1.google建议不要在scrollview中使用webview,但是毕竟无法避免,产品的需求 2.每次加载新的url的时候remove掉旧的webview,重新加入一个新的webview去加载这个新url,这种方案是可行的,但是毕竟不太好,效率不高 3.js注入 [java] view plain copy mWebView.setWebViewClient(new

2016-05-18 0comments 129hotness 0likes mikebai Read all
dev

Android应用使用自定义字体的一些探究

最近团队里面在做程序界面统一的工作,因此希望统一字体,接到一个研究怎么自定义字体的任务。因为我们的开发模式,所以需要研究在界面内的字体自定义,以及webview的显示中的字体自定义。 android系统内置字体 android 系统本身内置了一些字体,可以在程序中使用,并且支持在xml配置textView的时候进行修改字体的样式。支持字段为android:textStyle ,android:typeface, android:fontFamily,系统内置了normal|bold|italic三种style, 内置了normal,sans,

2016-05-08 0comments 112hotness 0likes mikebai Read all
dev

android webview使用自定义字体

<html> <head>    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">     <style type="text/css">         @font-face         {        font-family: "Kingsoft Phonetic Plain";         src: url('file:///android_asset/fonts/KingSoft.ttf');         }     </style> </head> <body> <font color="#FB8C42" face="Kingsoft Phonetic Plain, Tahoma">(9IntL`Akt; 9intEr5Akt)</font>

2016-05-08 0comments 115hotness 0likes mikebai Read all
dev

更改安卓app当前语言

来源 http://stackoverflow.com/questions/2900023/change-language-programatically-in-android http://gunhansancar.com/change-language-programmatically-in-android/ Change Language Programmatically in Android While developing your awesome application, sometimes you are required to add a feature to change the language of your app on the fly. However, Android OS does not directly support this behaviour. And therefore, you need to solve this situation in some other ways. Android by default uses the locale of the device to select the appropriate language dependent resources. And most of the time this behaviour is enough for common applications. However, sometimes there is some business requirements that you need to implement. To do that I will outline the details of changing the language of your application programmatically on the fly. Here is the appropriate way of changing the locale of the application: There are some difficulties which you have to overcome to change the language programmatically. Your application will 

2016-05-07 0comments 143hotness 0likes mikebai Read all
1…2223242526…62

Recent Posts

  • c# winform适配高dpi
  • com.microsoft.sqlserver.jdbc.SQLServerException “trustServerCertificate”属性设置为“false”,但驱动程序无法使用安全套接字层 (SSL) 加密与 SQL Server建立安全连接
  • java -cp 用法介绍
  • HTML 容器元素
  • MVC的cshtml的介绍

Recent Comments

No comments to show.

COPYRIGHT © 2025 mikebai.com. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang