小编Dan*_*ews的帖子

使用Java控制Arduino

我希望用Java程序打开和关闭LED.我在大约5分钟内完成了C#中的项目,但在Java中似乎更具挑战性.我让Arduino等待1或0写入COM端口,并根据它改变LED.我用于Arduino的代码如下.

int LedPin = 13;
char data;

void setup()
{
    Serial.begin(9600);
    pinMode( LedPin , OUTPUT );
}

void loop()
{
    data = Serial.read();
    if (Serial.available() > 0)
    {
        if(data == '1' )
        {
            digitalWrite(LedPin,HIGH);
        }
        else if(data == '0' )
        {
            digitalWrite(LedPin,LOW);
        }
    }
    else
        if (Serial.available()<0)
        {
            digitalWrite(LedPin,HIGH);
            delay(500);
            digitalWrite(LedPin,LOW);
            delay(500);
        }
}
Run Code Online (Sandbox Code Playgroud)

我如何使用Java应用程序执行此操作?

java eclipse arduino jarduino

15
推荐指数
3
解决办法
6万
查看次数

Android通知操作未调用待处理的服务意图

我试图让我的通知有一个按钮,当点击它应该调用我的服务,这是控制音频播放.

这是我的意图通知

        Intent intent = new Intent(context, AudioStreamService.class);


    Random generator = new Random();


    PendingIntent i = PendingIntent.getActivity(context, 579, intent,PendingIntent.FLAG_UPDATE_CURRENT);


    final NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
            .setSmallIcon(R.drawable.ic_launcher)
            .setContentTitle(title)
            .setContentText(text)
            .setPriority(NotificationCompat.PRIORITY_DEFAULT)
            .setLargeIcon(picture)
            .setTicker(ticker)
            .setNumber(number)
            .setOngoing(true)
            .addAction(
               R.drawable.ic_action_stat_reply,
               res.getString(R.string.action_reply),
               i);

    notify(context, builder.build());
Run Code Online (Sandbox Code Playgroud)

这是我服务的开始

    public int onStartCommand(Intent intent, int flags, int startId) {
    Log.e("APP ID", "APP ID - service called ");

    if(isPlaying){
        stop();
    }
    else {
        play();
    }
    return Service.START_STICKY;
}
Run Code Online (Sandbox Code Playgroud)

从通知中的操作调用时,永远不会触发日志.但该服务由应用程序中的按钮使用,并且工作正常.按以下命令调用日志.

android android-intent android-service android-notifications

8
推荐指数
1
解决办法
4824
查看次数

通过c#控制VLC

我正在编写一个应用程序,它将打开vlc,将文件添加到其播放列表中,然后播放它.我在最后2个问题上遇到了一些问题.

 AXVLC.VLCPlugin alxplugin1 = new AXVLC.VLCPlugin();

                alxplugin1.addTarget("C:\\test.avi", null, AXVLC.VLCPlaylistMode.VLCPlayListInsert, 0);
                alxplugin1.play();
Run Code Online (Sandbox Code Playgroud)

这不起作用......有什么想法吗?

谢谢

c# vlc

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

在android中根据端口(网络发现)查找本地网络上的机器

我希望让我的 Android 应用程序扫描本地网络 192.168.1.1-254 上的每台电脑,寻找打开某些给定端口的机器。我知道一些手动方法可以做到这一点,但这将是大量的代码,并且每次需要搜索时都需要一段时间。有没有一种快速的方法来指定端口并在打开的情况下搜索本地设备?

前任。桌面在端口 8888 上有 Web 服务器,您知道端口但不知道 IP,为应用程序提供端口并让它快速显示 IP。

java android network-programming

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

SwipeRefreshLayout选项卡布局。Webview无法向上滚动

好的,我有一个Tab视图,其中有一个Web视图,一个ListView和其他一些页面。我希望能够执行SwipeRefreshLayout刷新每个项目。我在每个页面上都在工作。但是,当我在Web视图中向下滚动时,无法向上滚动。它触发刷新并重建它。我希望能够在Web视图中向上滚动。

布局的东西

<android.support.v4.widget.SwipeRefreshLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/swipe_container"
    android:layout_width="match_parent"
    android:layout_height="20px"
    android:layout_weight="1"
    android:nestedScrollingEnabled="true">


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Splash$PlaceholderFragment">

    <TextView
        android:id="@+id/section_label"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <WebView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/webView"
        android:layout_alignParentTop="true"
        android:layout_alignParentStart="true"
        android:overScrollMode="ifContentScrolls"
        android:nestedScrollingEnabled="false"/>

    <ProgressBar
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/progressBar"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true" />

    <ListView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/listView"
        android:layout_centerVertical="false"
        android:layout_centerHorizontal="true"
        android:visibility="visible" />

</RelativeLayout>
</android.support.v4.widget.SwipeRefreshLayout>
Run Code Online (Sandbox Code Playgroud)

SwipeRefreshLayout在片段内用于我的选项卡式布局。

        swipeLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipe_container);

        swipeLayout.setColorScheme(android.R.color.holo_blue_bright,
                android.R.color.holo_green_light,
                android.R.color.holo_orange_light,
                android.R.color.holo_red_light);
        swipeLayout.setOnRefreshListener( new SwipeRefreshLayout.OnRefreshListener() {

                @Override public void onRefresh() {
                    if(getArguments().getInt(ARG_SECTION_NUMBER) == 4 ) {
                        stringArrayList.clear();
                        new updatetheQueue().execute(ctx);
                    }
                    else {
                        swipeLayout.setRefreshing(false);
                    }
                }});
Run Code Online (Sandbox Code Playgroud)

android webview swiperefreshlayout

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