小编Har*_*ana的帖子

YouTubePlayer无法使用cueVideo()加载广告视频

我正在YouTubePlayer播放YouTube视频并用于cueVideo(videoId)加载视频,如果视频不包含广告但视频包含广告则cueVideo(videoId)不会加载视频.

也看到一些讨论关于这个问题,建议使用loadVideo(videoId)而不是cueVideo(videoId)根据我的要求我显示图像,直到视频不缓冲和视频缓冲隐藏图像和显示YouTubePlayer,所以必须使用cueVideo(videoId)而不是loadVideo(videoId).

有没有人有这样的问题?提前感谢任何建议或帮助.

以下是我加载视频的代码:

 youTubePlayer.cueVideo(videoId);
Run Code Online (Sandbox Code Playgroud)

android android-youtube-api

11
推荐指数
1
解决办法
2071
查看次数

Color.parseColor返回负数

我刚尝试过这样做

System.out.println("color == " + Color.parseColor("#F5F5F5"));
Run Code Online (Sandbox Code Playgroud)

然后它返回就像

color == -657931
Run Code Online (Sandbox Code Playgroud)

谁知道为什么,拜托?

android

6
推荐指数
2
解决办法
3716
查看次数

Android 权限:应用程序崩溃需要蓝牙权限

我最近正在创建一个使用蓝牙的应用程序。问题是当我启动蓝牙服务时我的应用程序崩溃了。这是我的清单文件

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="in.petalappstudio.fit" >

<uses-permission android:name="ANDROID.PERMISSION.BLUETOOTH"/>
<uses-permission android:name="ANDROID.PERMISSION.BLUETOOTH_ADMIN"/>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <service
        android:name=".bluetoothManager"
        android:enabled="true"
        android:exported="true">
    </service>
</application>
Run Code Online (Sandbox Code Playgroud)

现在,如您所见,我已经添加了蓝牙和蓝牙管理员的权限。

我的应用程序如何崩溃并且在 LOGCAT 中错误是

"java.lang.RuntimeException: Unable to start service " and is caused by
"java.lang.SecurityException: Need BLUETOOTH ADMIN permission: Neither user 10145 nor current process has android.permission.BLUETOOTH_ADMIN."
Run Code Online (Sandbox Code Playgroud)

但我已经添加了权限,如您所见。现在为什么会发生这种情况?

android bluetooth android-bluetooth

6
推荐指数
1
解决办法
5681
查看次数

如何使用OpenCV从图像中检测(计数)头发?

我尝试下面使用代码OpenCV的功能cvtColor,CannyHoughLinesP却没有能够得到精确的结果,或在某些情况下无法正常工作.

private boolean opencvProcessCount(Uri picFileUri) {
hairCount = 0;
totalC = 0;
//Log.e(">>>>>>>>","count " + picFileUri);
try {
    InputStream iStream = getContentResolver().openInputStream(picFileUri);
    byte[] im = getBytes(iStream);
    BitmapFactory.Options opt = new BitmapFactory.Options();
    opt.inDither = true;
    opt.inPreferredConfig = Bitmap.Config.ARGB_8888;
    Bitmap image = BitmapFactory.decodeByteArray(im, 0, im.length);

    Mat mYuv = new Mat();
    Utils.bitmapToMat(image, mYuv);
    Mat mRgba = new Mat();
    Imgproc.cvtColor(mYuv, mRgba, Imgproc.COLOR_RGB2GRAY, 4);
    Imgproc.Canny(mRgba, mRgba, 80, 90);
    Mat lines = new Mat();
    int threshold = 80; …
Run Code Online (Sandbox Code Playgroud)

android opencv opencv4android opencv3.1

6
推荐指数
1
解决办法
815
查看次数

找不到id ... for fragment PlaceholderFragment的视图

我有一个简单的应用程序(基于Android First App示例); 它唯一能做的就是显示一个EditText和一个按钮.该按钮创建另一个活动,并显示EditText消息......简单!...但是当在模拟器上运行时,当我点击按钮时应用程序关闭,我收到此错误:

"对于片段PlaceholderFragment {4173ead8#0 id = 0x7f05003c},找不到id 0x7f05003c(com.example.testapp:id/container)的视图"

MainActivity.java

public class MainActivity extends ActionBarActivity {

public final static String EXTRA_MESSAGE = "com.example.testapp.MESSAGE";

public void SendMessage (View view) {
    Intent intent = new Intent(this, DisplayMessageActivity.class);
    EditText editText = (EditText) findViewById(R.id.edt_message);
    String message = editText.getText().toString();
    intent.putExtra(EXTRA_MESSAGE, message);
    startActivity(intent);
}

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction()
                .add(R.id.container, new PlaceholderFragment())
                .commit();
    }
}


@Override
public boolean onCreateOptionsMenu(Menu menu) {

    // Inflate the …
Run Code Online (Sandbox Code Playgroud)

android android-fragments

5
推荐指数
1
解决办法
1万
查看次数

在构建Android项目时添加dexdebug错误

Gradle Build控制台显示此消息.

Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2
Run Code Online (Sandbox Code Playgroud)

我被告知这个问题是由于build.gradle文件上的错误设置造成的.我的gradle文件看起来像这样.

apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc2"

defaultConfig {
    applicationId "com.marshall.gruppo"
    minSdkVersion 15
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile project(':volley')
compile project(':android-support-v4')
}
Run Code Online (Sandbox Code Playgroud)

我应该在这里解决什么?

android gradle

5
推荐指数
1
解决办法
1285
查看次数

在Android Studios build.gradle中,我在哪里可以找到"项目"文件?

我刚刚在android studio中导入了facebook模块的build.grade文件,它包含以下代码:

defaultConfig {
    minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
    targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
}
Run Code Online (Sandbox Code Playgroud)

我的问题是'项目'指向哪个文件?

sdk android facebook

2
推荐指数
1
解决办法
981
查看次数

带有模糊层的谷歌地图

我正在启动一个新的 android 应用程序,我将使用谷歌地图,我也是设计师,正在寻找灵感我找到了这个截图:http : //cdn1.appleinsider.com/Maps.071213.2.jpg
我真的很喜欢左边的屏幕和特别是图像底部的模糊层(带有信息图标的层)。

我正在阅读有关如何使用 android 进行模糊处理的内容,但所有内容都在使用图片、位图、ImageView,而没有使用地图。所以我的问题是:
我可以在 android 上制作类似的东西(类似于 iOS 屏幕截图)吗?
谢谢你。

android google-maps

2
推荐指数
1
解决办法
2621
查看次数

Android:动作栏主页按钮获得额外的填充

我正在开发一个应用程序,我在其中自定义操作栏,如图所示:

行动吧

我的代码如下:

// Remove all tabs from actionbar
getActionBar().removeAllTabs();

final ViewGroup actionBarLayout = (ViewGroup)getLayoutInflater().inflate(R.layout.custom_actionbar_layout, null);
// set custom layout for menus on actionbar
getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_USE_LOGO);
getActionBar().setCustomView(actionBarLayout);

getActionBar().setBackgroundDrawable(new ColorDrawable(Color.WHITE));
getActionBar().setDisplayHomeAsUpEnabled(false);
getActionBar().setLogo(R.drawable.ic_back_orange);

final TextView textViewOfActionBarHeading = (TextView) actionBarLayout.findViewById(R.id.textView_actionar_heading);
textViewOfActionBarHeading.setText("My Activity");

// Getting the reference of searchViewand TextView of searchView
SearchView searchView = (SearchView) actionBarLayout.findViewById(R.id.searchView_actionar_search);
searchView.setIconifiedByDefault(true);
final TextView search_text = (TextView) searchView.findViewById(searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null));

// Set color to TextView of searchView
search_text.setTextColor(Color.BLACK);
// Set hint to TextView of …
Run Code Online (Sandbox Code Playgroud)

android android-custom-view android-actionbar

-1
推荐指数
1
解决办法
1725
查看次数