小编Pra*_*tik的帖子

如何使用kml文件在地图上绘制路径?

我可以解析kml文件以显示Android中的路径或点吗?请你能帮助我吗?

这是kml示例代码,我想在android谷歌地图中显示:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>Paths</name>
<description>Examples of paths. Note that the tessellate tag is by default
  set to 0. If you want to create tessellated lines, they must be authored
  (or edited) directly in KML.</description>
<Style id="yellowLineGreenPoly">
  <LineStyle>
    <color>7f00ffff</color>
    <width>4</width>
  </LineStyle>
  <PolyStyle>
    <color>7f00ff00</color>
  </PolyStyle>
</Style>
<Placemark>
  <name>Absolute Extruded</name>
  <description>Transparent green wall with yellow outlines</description>
  <styleUrl>#yellowLineGreenPoly</styleUrl>
  <LineString>
    <extrude>1</extrude>
    <tessellate>1</tessellate>
    <altitudeMode>absolute</altitudeMode>
    <coordinates> -112.2550785337791,36.07954952145647,2357
      -112.2549277039738,36.08117083492122,2357
      -112.2552505069063,36.08260761307279,2357
      -112.2564540158376,36.08395660588506,2357
      -112.2580238976449,36.08511401044813,2357
      -112.2595218489022,36.08584355239394,2357
      -112.2608216347552,36.08612634548589,2357
      -112.262073428656,36.08626019085147,2357
      -112.2633204928495,36.08621519860091,2357
      -112.2644963846444,36.08627897945274,2357
      -112.2656969554589,36.08649599090644,2357 
    </coordinates>
    <LineString>
    </Placemark>
    </Document>
    </kml> …
Run Code Online (Sandbox Code Playgroud)

android google-maps kml android-mapview

96
推荐指数
3
解决办法
10万
查看次数

无法添加窗口android.view.ViewRoot$W@44da9bc0 - 此窗口类型的权限被拒绝

我比较喜欢这篇文章但是我在将viewgroup添加到windowmanager对象时遇到了错误,我已经使用相同的服务类来发布到问题而没有任何变化,我可能会误认为我没有得到它

WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
wm.addView(mView, params); // here
Run Code Online (Sandbox Code Playgroud)

当我向WindowManger添加视图时

这是我的清单文件

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.searce.testoverlay"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="7" />

    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name="TestOverlayActivity"
                      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:enabled="true" android:name=".HUD"></service>
    </application>
</manifest>
Run Code Online (Sandbox Code Playgroud)

错误

09-27 18:49:23.561: ERROR/AndroidRuntime(653): Uncaught handler: thread main exiting due to uncaught exception
09-27 18:49:23.571: ERROR/AndroidRuntime(653): java.lang.RuntimeException: Unable to create service com.searce.testoverlay.HUD: android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRoot$W@44da9bc0 -- permission denied for this window type …
Run Code Online (Sandbox Code Playgroud)

android overlay

82
推荐指数
2
解决办法
7万
查看次数

检索项目的父项时出错:找不到与给定名称匹配的资源'@android:style/TextAppearance.Holo.Widget.ActionBar.Title'

我正在实现ActionBar来使用xml中的这个样式脚本设置文本的颜色但是当我运行我的应用程序时间时收到错误确实有人知道我遗漏了什么

这是我的style.xml文件

<!-- Start with the Holographic Light theme -->
<style name="Theme.IOSched" parent="android:style/Theme.Holo.Light">
    <item name="android:windowBackground">@drawable/window_background</item>
    <item name="android:actionBarStyle">@style/ActionBar</item>

    <!-- custom attributes 
    <item name="textHeaderMaxLines">@integer/text_header_max_lines</item>
    <item name="trackAbstractMaxLines">@integer/track_abstract_max_lines</item>-->
</style>

<style name="Theme.IOSched.Home" parent="style/Theme.IOSched">
    <item name="android:windowBackground">@drawable/window_background_home</item>
    <item name="android:actionBarStyle">@style/ActionBar</item>
</style>

<style name="ActionBar" parent="android:style/Widget.Holo.Light.ActionBar">
    <item name="android:background">@color/actionbar_background</item>
    <item name="android:textColor">@color/accent_1</item>
    <item name="android:titleTextStyle">@style/ActionBarText</item>
</style>

<style name="ActionBarText" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title"> <!-- getting here error-->
    <item name="android:textColor">@color/accent_1</item>
    <item name="android:textStyle">bold</item>
</style>

error: Error retrieving parent for item: No resource found that matches the given name '@android:style/TextAppearance.Holo.Widget.ActionBar.Title'.
Run Code Online (Sandbox Code Playgroud)

android coding-style

53
推荐指数
3
解决办法
16万
查看次数

android自定义网址方案..?

我试图创建自己的网址方案,以便我的Android应用程序可以通过URL调用,但现在我没有成功.

我试图让这个网址工作:cedemo://com.cedemo.scan?X = toto

这是我的清单文件的一部分:

<activity android:name=".Gallery1" android:label="@string/app_name" android:launchMode="singleTask" android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.GALLERY" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="cedemo" android:host="com.cedemo.scan" />

        </intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)

有没有人可以帮我告诉我什么是错的?此外,如果有人发现错误,有人可以告诉我如何从我的应用程序的Android代码中读取"X"变量?


更新:

更新:我做了动作的修改(正如其中一个答案中所建议的那样)并且它运行良好.问题是我仍然无法获取url变量值.这是我试过的代码.

final Intent intent = getIntent();
final String myScheme=intent.getScheme();
final Bundle myBundle=intent.getExtras();
final boolean inContestKey;
if (myBundle != null) {
    inContestKey=myBundle.containsKey("inContest");
}
final Uri myURI=intent.getData();
final String value;
if (myURI != null) {
    value = myURI.getQueryParameter("inContest");
}
Run Code Online (Sandbox Code Playgroud)

但我收到null了所有的功能......我还能做什么?

可能我应该更好地解释我的软件的上下文:

  1. 我的软件已启动
  2. 我的软件然后启动浏览器
  3. 用户单击浏览器中的链接,浏览器转到url方案,返回到带有变量"X"的软件(例如)
  4. 软件应该读取变量"X"

但在我的情况:myScheme,myBundle,myURI设置为 …

url android

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

设置视图文本在android中的微调器中心对齐

视图文本中最中心的最微调 - 当 - 选择 - 来自该下拉列表

我想将微调器的视图文本与中心对齐.我谷歌但没有找到任何东西,有人知道吗?任何帮助或建议表示赞赏

android text-alignment android-spinner

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

为什么在使用反射调用方法时,"对象不是声明类的实例"?

public class Shared {

    public static void main(String arg[]) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
        Shared s1 = new Shared();

        Object obj[] = new Object[2];
        obj[0] = "object1";
        obj[1] = "object2";
        s1.testParam(null, obj);

        Class param[] = new Class[2];
        param[0] = String.class;
        param[1] = Object[].class; //// how to define the second parameter as array
        Method testParamMethod = s1.getClass().getDeclaredMethod("testParam", param);
        testParamMethod.invoke("", obj); ///// here getting error
    }

    public void testParam(String query,Object ... params){
        System.out.println("in the testparam method");
    }

}
Run Code Online (Sandbox Code Playgroud)

这是输出:

in …
Run Code Online (Sandbox Code Playgroud)

java reflection illegalargumentexception

32
推荐指数
2
解决办法
7万
查看次数

FragmentActivity无法解析为某种类型

我正在尝试从这个博客的应用程序.在扩展时FragmentActivity,我收到以下错误:

`FragmentActivity` was not able to resolve.
Run Code Online (Sandbox Code Playgroud)

我错过了任何图书馆还是其他什么?

我的代码:

public class Testing_newActivity extends FragmentActivity { // here the FragmentActivity getting error package not found for import
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.main);
        if (getResources().getConfiguration().orientation
                == Configuration.ORIENTATION_LANDSCAPE) {
            // If the screen is now in landscape mode, we can show the
            // dialog in-line so we don't need this activity.
            finish();
            return;
        }

        if (savedInstanceState == …
Run Code Online (Sandbox Code Playgroud)

android android-fragmentactivity

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

实现扩展和折叠通知android

我需要在Android 4.0及更高版本的状态栏中实现扩展和折叠通知.我在google上搜索了这个,但没有得到任何代码解决方案实现有没有人知道如何实现这一点

先感谢您

notifications android

29
推荐指数
2
解决办法
4万
查看次数

动态生成的线条,有效发光

我想用这样的发光效果绘制线条
发光线
问题 - 我必须根据用户的交互在程序中生成这一行(行的形式将在onTouchEvent- 中生成ACTION_MOVE).

我可以在没有xml文件或绘制premaid位图的情况下生成此效果吗?

android paint touch-event

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

单击小部件启动活动

我在编程Android的新手,我尝试做一个小部件,可以从ISP获取有关我的帐户的一些数据.有很多未知的事情如何做,但我做了一些事情 - 我有一个配置活动的小部件,用户应该键入登录名和密码.窗口小部件将数据存储在SharedPerferences中,当需要更新窗口小部件时,我使用服务启动AsyncTask以从ISP获取帐户数据.现在我想通过点击小部件来开始一项活动.我已经尝试了我在这个网站上找到的所有建议,而且widget无法启动活动.我的小部件基于另一个小部件放在这里https://github.com/Arturus/MetrikaWidget.我不明白我应该通过点击我的小部件来改变什么以及在哪里开始活动.谢谢.

更新:我的更新功能,我建议我应该放置PendingIntent

@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)
{
    Log.d(TAG, "onUpdate");

    for (int appWidgetId : appWidgetIds)
    {
        updateAppWidget(context, appWidgetManager, appWidgetId);
    }

    /* An updateAppWidget functions looks like as:

    Intent intent = new Intent(context, UpdateWidgetService.class);
    intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);
    context.startService(intent);
    */

    Intent intent = new Intent(context, DetailedStatActivity.class);
    PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, 0);

    RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.layout);

    views.setOnClickPendingIntent(R.id.layout, pendingIntent);

    ComponentName componentName = new ComponentName(context.getPackageName(), WidgetProvider.class.getName());

    appWidgetManager.updateAppWidget(componentName, views);
}
Run Code Online (Sandbox Code Playgroud)

android widget click android-activity

22
推荐指数
2
解决办法
3万
查看次数