跳到主要內容

發表文章

error android api 34 java.lang.RuntimeException: Unable to create service org.altbeacon.beacon.service.BeaconService: android.app.MissingForegroundServiceTypeException: Starting FGS without a type callerApp=ProcessRecord

在建置API34 時 出現java.lang.RuntimeException: Unable to create service org.altbeacon.beacon.service.BeaconService: android.app.MissingForegroundServiceTypeException: Starting FGS without a type callerApp=ProcessRecord 在 manifest 新增 <service android :name ="org.altbeacon.beacon.service.BeaconService" android :foregroundServiceType ="location" />

android holder.binding.videoview cannot be played Url

 Recently, Videoview was added to the implementation of RecyclerView, and there was a display error W/Glide: Cannot find GeneratedAppGlideModule. You should include the annotationProcessor compilation dependency on com.github.bumptech.glide:compiler and AppGlideModule in your application holder.binding.videoview.getLayoutParams().height = getScreenWidth (context) * 9 /16; holder.binding.videoview.getLayoutParams().width = getScreenHight (context) * 9 /16; public static int getScreenWidth(Context c) { int screenWidth = 0; // this is part of the class not the method if (screenWidth == 0) { WindowManager wm = (WindowManager) c.getSystemService(Context. WINDOW_SERVICE ); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); screenWidth = size.x; } return screenWidth; } public static int getScreenHight(Context c) { int screenHeight = 0; // this is part of the class not the method if (scr...

Android平台下使用GStreamer How to build GStreamer

  GStreamer 環境建置 設備環境 : OS: Windows 10 專業版 Android Studio: 4.0.1 classpath 'com.android.tools.build:gradle:3.1.4' GStreame SDK : 1.18.4     1.       GStreame 官方網站,下載 GStreameSDK 點選 android Tutorials 官方安裝說明 點選 GStreamer binaries   下載 GStreameSDK ,這邊點選 1.18.4 tarball 及 Android NDKs used r21 GStreameSDK 解壓縮內容 建立資料夾命名 GStreameSDK ,存放至 C:\GStreameSDK\1.18.4\ Android NDK 2.       下載 GStreamer 官方範例,點選左邊連結連至 GStreame gitlab ,並點選 gst-doc s 下載範例 gst-docs 3.       載入專案,點選 File->New->ImportProject 新增 gradel.properties gstAndroidRoot = C \:\\ GStreamerSDK \\ 1.18.4 此路徑為剛下載的 GStreamerSDK 位置 gradel.properties 畫面 中間會出現 Exception 錯誤 修改為 ->Exception 出現 GStreamer 未能使用,將 GStreamer.java 複製至專案內 複製位置,將所有 tutorials1-4 資料夾內都複製貼上 編譯完成顯示在實機上

Error : android.os.FileUriExposedException

android.os.FileUriExposedException RootCause:從Android 7.0開始,一個應用提供自身檔案給其它應用使用時,如果給出一個file://格式的URI的話,應用會丟擲FileUriExposedException。這是由於谷歌認為目標app可能不具有檔案許可權,會造成潛在的問題。 Solution: 使用FileProvider code java Uri uri=FileProvider. getUriForFile (context , context . getApplicationContext (). getPackageName () , imgFile) ; // Uri uri = Uri.fromFile(imgFile); or FileProvider. getUriForFile (context , context . getApplicationContext (). getPackageName () , mCsvFile ) android mainfest <provider android :name ="android.support.v4.content.FileProvider" android :authorities ="PackageName.fileprovider" android :exported ="false" android :grantUriPermissions ="true" > <meta-data android :name ="android.support.FILE_PROVIDER_PATHS" android :resource ="@xml/file_paths" /> </provider> add xml file  file name   file_paths...

error : java.lang.RuntimeException: Stub!

原因: 在android 9.0 ,Apache HTTP client, 已经从bootClassLoader 里面移除了。 我们可以看下android 官网自己说的: 2020-05-19 14:17:44.434 31933-32402/com.taidoc.tdlink.cs E/UploadRecordService: upload fail     java.lang.RuntimeException: Stub!         at org.apache.http.params.AbstractHttpParams.<init>(AbstractHttpParams.java:6)         at org.apache.http.params.BasicHttpParams.<init>(BasicHttpParams.java:7) <uses-library android:name="org.apache.http.legacy" android:required="false"/>

Caused by: java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation

Caused by: java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation 如題 在其他裝置都不會出現,目前出現在samsung S8 amdroid 8上出現 在 AndroidManifest 裡有使用到 android :theme ="@style/Theme.FullScreenDialog"某個style  到該style裡修改 <item name ="android:windowIsTranslucent" > false </item> <item name ="android:windowDisablePreview" > true </item>---->add

android eclipse transformation to android studio Error AAPT: error: style attribute 'attr/@attr/colorChecked (aka com.xxxxx:attr/@attr/colorChecked)' not found.

AAPT: error: style attribute 'attr/@attr/colorChecked 刪除 " @attr/" 即可!!

android studio build Error Duplicate resources

build Error Duplicate resources  drawable 目錄圖片和xml名字一樣,修改 就可以了 刪除 .9.png 即可

IOS Swift 擷取當前螢幕產生縮圖

         func screenshot() -> UIImage {             var imageSize = CGSize.zero                  let orientation = UIApplication.shared.statusBarOrientation             if UIInterfaceOrientationIsPortrait(orientation) {                 imageSize = UIScreen.main.bounds.size             } else {                 imageSize = CGSize(width: UIScreen.main.bounds.size.height, height: UIScreen.main.bounds.size.width)             }                  UIGraphicsBeginImageContextWithOptions(imageSize, false , 0 )             for window in UIApplication.shared.windows {               ...

IOS Swift 在某路徑下產生檔案 txt json

語法:         func createFile(name: String , fileBaseUrl: URL ){             let manager = FileManager . default                          let file = fileBaseUrl. appendingPathComponent (name)             print ( "文件: \ ( file )" )             let exist = manager. fileExists (atPath: file. path )             if !exist {                 let data = Data (base64Encoded: "aGVsbG8gd29ybGQ=" ,options:. ignoreUnknownCharacters )                 let createSuccess = manager. createFile (atPath: file. path ,contents:data,attributes: nil )                 print ( "文件產生结果: \ ( createSuccess )" )             } ...

暫存

Documents : 存放应用程序产生的数据,会被itunes备份同步 Library : 包含两个子目录:Caches 和 Preferences Preferences:包含应用程序的偏好设置文件。您不应该直接创建偏好设置文件,而是应该使用NSUserDefaults类来取得和设置应用程序的偏好,会被itunes备份同步. Caches:用于存放应用程序专用的支持文件,保存应用程序再次启动过程中需要的信息,不会被itunes备份同步。 tmp : 存放临时数据,当不在用时应该删除掉临时文件,系统也有可能在程序不运行时删除该文件夹下内容 ##获取目录方法 ###Home目录 //获取沙盒主目录路径 var homeDir=NSHomeDirectory() println ( "\(dirHome)" ) ###Documents目录 //获取Documents目录路径 var paths = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory .DocumentDirectory , NSSearchPathDomainMask .UserDomainMask , true) var documentsDirectory = paths[ 0 ] as! String println( "\(documentsDirectory)" ) 或者相对Home路径 var documentsDirectory = NSHomeDirectory ().stringByAppendingPathComponent( "Documents" ) println ( " \(documentsDirectory) " ) ###Library目录 // 获取Library目录路径 var paths = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory .LibraryDirectory , NSSearchPathDomainMask .UserDom...