我正在尝试使用后台服务拍摄屏幕截图。该服务就像一个Facebook聊天头,但是我希望它在单击时拍摄屏幕截图。
我已经开发了一些代码,但是没有用。我尝试过的最后一个是:
private void takeScreenshot() {
Date now = new Date();
android.text.format.DateFormat.format("yyyy-MM-dd_hh:mm:ss", now);
// image naming and path to include sd card appending name you choose for file
String mPath = Environment.getExternalStorageDirectory().toString() + "/capture/" + now + ".jpg";
// create bitmap screen capture
Bitmap bitmap;
View v1 = chatHead.getRootView();
v1.setDrawingCacheEnabled(true);
bitmap = Bitmap.createBitmap(v1.getDrawingCache());
v1.setDrawingCacheEnabled(false);
OutputStream fout = null;
File imageFile = new File(mPath);
try {
fout = new FileOutputStream(imageFile);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fout);
fout.flush();
fout.close();
} catch (FileNotFoundException e) { …Run Code Online (Sandbox Code Playgroud) 我正在 Android Studio 中开发一个应用程序,它运行得很好,但是在实现了我的启动活动的深层链接后,我的应用程序没有菜单中的应用程序图标,我知道该应用程序已安装,因为在“设置”>“应用程序”中它出现。我知道问题出在manifest.xml 中,所以我会在下面留下一份副本。
\n\n顺便说一句,如果您正在阅读本文,我很想听听您的解决方案,谢谢。
\n\n<?xml version="1.0" encoding="utf-8"?>\n<manifest xmlns:android="http://schemas.android.com/apk/res/android"\n package="com.dev.misterj.nocherd">\n\n <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />\n <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />\n <uses-permission android:name="android.permission.INTERNET" />\n <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />\n <uses-permission android:name="android.permision.CALL_PHONE"/>\n <uses-permission android:name="android.permission.MANAGE_OWN_CALLS"/>\n <uses-permission android:name="android.permission.READ_CALL_LOG"/>\n <uses-permission android:name="android.permission.READ_PHONE_STATE"/>\n\n\n <meta-data\n android:name="com.google.android.geo.API_KEY"\n android:value="AIzaSyAiJNpq-********************" />\n\n <application\n android:allowBackup="true"\n android:icon="@mipmap/ic_launcher"\n android:label="@string/app_name"\n android:roundIcon="@mipmap/ic_launcher_round"\n android:supportsRtl="true"\n android:usesCleartextTraffic="true"\n android:networkSecurityConfig="@xml/network_security_config"\n android:theme="@style/AppTheme">\n\n <activity android:name=".StartActivity">\n <intent-filter>\n <action android:name="android.intent.action.MAIN" />\n <category android:name="android.intent.category.LAUNCHER" />\n <action android:name="android.intent.action.VIEW"/>\n <category android:name="android.intent.category.DEFAULT"/>\n <category android:name="android.intent.category.BROWSABLE" />\n\n <!-- Accepts URIs that begin with "https://myapp.com/place\xe2\x80\x9d -->\n <data android:scheme="https" android:host="myapp.com" android:pathPrefix="/place" />\n <!-- Accepts URIs that begin …Run Code Online (Sandbox Code Playgroud)