如何在下载图像和更新通知期间删除此错误.
java.lang.SecurityException:用户10080和当前进程都没有android.permission.WAKE_LOCK.在android.os.Parcel.readException(Parcel.java:1425)的android.os.Parcel.readException(Parcel.java:1379)android.os.IPowerManager $ Stub $ Proxy.acquireWakeLock(IPowerManager.java:326)at at android.os.PowerManager $ WakeLock.acquireLocked(PowerManager.java:309)at android.os.PowerManager $ WakeLock.acquire(PowerManager.java:300)at android.app.NotificationManager.notify(NotificationManager.java:128)at android .app.NotificationManager.notify(NotificationManager.java:104)
我的屏幕尺寸为600(宽)x 1024(高).我得到当前宽度600但错误地获得高度976(没有旋转屏幕).我得到当前宽度1024但错误得到高度552(旋转屏幕).
int rowPixelWidth = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getWidth();
int rowWidth = (int)Math.floor(rowPixelWidth / this.getResources().getDisplayMetrics().density);
int rowPixelheight = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getHeight();
int rowheight = (int)Math.floor(rowPixelheight / this.getResources().getDisplayMetrics().density);
Log.d("rowWidth","rowWidth"+rowWidth);
Log.d("rowheight","rowheight"+rowheight);
-------------------------------------------------------------
<uses-sdk
android:minSdkVersion="3"
android:targetSdkVersion="8" />
<supports-screens android:anyDensity="true"/>
-------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)
这段代码出了什么问题?
以下是典型屏幕宽度的一些数字:
我获得当前宽度但没有获得所有设备的当前高度(没有(320x480屏幕).
我尝试以像素为单位获取屏幕尺寸的代码,但同样会出现问题.
我从Youtube搜索列表实现youtube搜索列表
但是出现了这个错误
访问未配置.请使用Google Developers Console激活项目的API
码:-
youtube = new YouTube.Builder(transport,jsonFactory, new HttpRequestInitializer()
{
@Override
public void initialize(HttpRequest request) throws IOException {
}
}).setApplicationName("youtube-cmdline-search-sample").build();
String queryTerm = getInputQuery();
// Define the API request for retrieving search results.
YouTube.Search.List search = youtube.search().list("id,snippet");
// Set your developer key from the Google Developers Console for
String apiKey = ""; //i have server key and browser key
search.setKey(apiKey);
search.setQ(queryTerm);
search.setType("video");
search.setFields("items(id/kind,id/videoId,snippet/title,snippet/thumbnails/default/url)");
search.setMaxResults(NUMBER_OF_VIDEOS_RETURNED);
Run Code Online (Sandbox Code Playgroud)