小编cod*_*lus的帖子

最佳实践 - 将您的应用程序添加到Android共享菜单

我的应用程序通过TCP连接发送文件(所有mime类型),因此我希望我的应用程序出现在Android Share菜单中.

我在我的Activity中添加了以下intent过滤器 AndroidManifest.xml

<intent-filter ><!--intent filter for single file sharing-->
    <action android:name="android.intent.action.SEND" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="*/*" />
</intent-filter>
<intent-filter ><!--intent filter for sharing multiple files-->
    <action android:name="android.intent.action.SEND_MULTIPLE" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="*/*" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)

现在我将其添加到Activity单击"共享操作"时要启动的内容

Intent intent = getIntent();
if (Intent.ACTION_SEND.equals(intent.getAction())) {
    Uri uri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
    if (uri != null) {
        fileset = new HashSet();
        fileset.add(getPathfromUri(uri));
    }
} else if (Intent.ACTION_SEND_MULTIPLE.equals(intent.getAction())) {
    ArrayList<Uri> uris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
    if (uris != null) {
        fileset = …
Run Code Online (Sandbox Code Playgroud)

android android-intent

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

Artifact尚未打包 - maven-dependency-plugin

当我构建一个多模块maven项目(使用mvn clean compile),其中一个依赖项(构建反应器的一部分)使用依赖项复制到另一个:复制,然后maven抱怨以下错误.

Artifact has not been packaged yet. When used on reactor artifact, copy should be executed after packaging: see MDEP-187 is thrown

这非常好,Maven无法复制依赖jar,因为它尚未打包,并且依赖性必须从本地项目而不是从存储库中解析.

让我们说项目A正在使用依赖项复制到项目B:复制目标.

现在,如果我将项目导入eclipse,生命周期映射的设置方式使得maven-jar-plugin在项目A上执行(这意味着A被打包),那么项目B仍抱怨同样的错误.我怎样才能摆脱这种情况.我不能忽视依赖:在m2e生命周期中复制,因为它是构建中的关键阶段.

ProjectA的pom文件:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <artifactId>projecta</artifactId>
    <packaging>jar</packaging>

    <parent>
        <groupId>com.coderplus.tests</groupId>
        <artifactId>projectparent</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>org.apache.maven.plugins</groupId>
                                        <artifactId>maven-jar-plugin</artifactId>
                                        <versionRange>[2.4,)</versionRange>
                                        <goals>
                                            <goal>jar</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <execute />
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>
Run Code Online (Sandbox Code Playgroud)

项目B的pom文件

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 …
Run Code Online (Sandbox Code Playgroud)

m2eclipse maven maven-dependency-plugin

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

在android中创建带圆角的Button

在此输入图像描述

我正在尝试创建一个看起来如上图所示的按钮.最初我的想法是创建一个9补丁并将其设置为按钮背景.但是,因为这是一个简单的按钮,我想我们可以在不使用任何图像的情况下以某种方式绘制它.

按钮背景颜色为#0c0c0c边框颜色为#1a1a1a文本颜色为#cccccc

我在SO上发现了一个类似的问题,但它创建了一个渐变 -
Android - 按钮的边框

android android-layout android-button

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

Holo的半透明对话主题

谁能帮我找到这个主题Holo的等效

 @android:style/Theme.Translucent.NoTitleBar
Run Code Online (Sandbox Code Playgroud)

我试过用

@android:style/Theme.Holo.DialogWhenLarge.NoActionBar
Run Code Online (Sandbox Code Playgroud)

但它不是半透明的.

android android-layout

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

最佳实践 - 将活动绑定到活动

我有一个在后台运行的网络服务.我mConnection在Activity中有这个全局变量

protected ServiceConnection mConnection = new ServiceConnection() {

    public void onServiceConnected(ComponentName className, IBinder binder) {
        serviceobject = ((NetworkService.MyBinder) binder).getService();
    }

    public void onServiceDisconnected(ComponentName className) {
        serviceobject = null;
    }
};
Run Code Online (Sandbox Code Playgroud)

然后我在Activity中onCreate(..)使用绑定服务

bindService(new Intent(this, NetworkService.class), 
                 mConnection,Context.BIND_AUTO_CREATE);
Run Code Online (Sandbox Code Playgroud)

NetworkService类有一个内部类MyBinder

public class MyBinder extends Binder {
    NetworkService getService() {
        return NetworkService.this;
    }
}
Run Code Online (Sandbox Code Playgroud)

现在从Activity调用任何Service方法,我使用serviceobject和我AsyncTask为每个方法调用创建一个.(我知道从Activity调用Service方法无效使用Services.I将它用于不涉及的轻量级方法很多计算)

这有助于我直接处理来自Service使用的数据serviceobject.我取消绑定服务中ActivityonDestroy()

@Override
protected void onDestroy()
{
    unbindService(mConnection);
    super.onDestroy();
}
Run Code Online (Sandbox Code Playgroud)

这是最好的方式,还是我错了?

android android-service android-activity

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

使用TCP通过网络传输文件(加快传输速度)

我一直试图通过Socket连接发送一个大文件,但它运行缓慢,我想知道是否可以通过某种方式优化此代码以提高传输速度.

这是我发送文件的代码:

byte[] buffer = new byte[65536];
int number;

while ((number = fileInputStream.read(buffer)) != -1) {
    socketOutputStream.write(buffer, 0, number);
}

socketOutputStream.close();
fileInputStream.close();
Run Code Online (Sandbox Code Playgroud)

这是我用来在另一台机器上接收文件的方法:

byte[] buffer = new byte[65536];

InputStream socketStream= clientSocket.getInputStream();
File f=new File("C:\\output.dat");

OutputStream fileStream=new FileOutputStream(f);

while ((number = socketStream.read(buffer)) != -1) {
    fileStream.write(buffer,0,number);
}

fileStream.close();
socketStream.close();
Run Code Online (Sandbox Code Playgroud)

我认为写入fileStream占用了大部分时间.任何人都可以提供加速此代码的任何建议.

java sockets performance networking

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

Jenkins Git插件试图在发行版本期间构建旧版本

我正在尝试使用发布Maven项目maven-release-plugin。Jenkins Git插件似乎无法正确签出存储库。

以下是我的Jenkins Job配置

仓库URL:git @ githubenterprise:/user/repo.git

要建立的分支:* / master

仓库浏览器:自动

其他行为:

  结帐到特定的本地分支:主

失败发行版的Git Build数据显示

修订:267 **
裁判/远程/起源/起源/大师
建分行

refs / remotes / origin / master:版本755的版本4 ** 
(参考/远程/原点/大师)
refs / remotes / origin / origin / master:版本267的内部版本10 *** 
(参考/远程/原点/来源/母版)

作业控制台显示

多个候选修订
计划另一个构建以赶上MyJenkinsBuildJob
检出267修订版**(参考/远程/原点/原点/主版)

755 **是存储库上的最新提交,而Git插件正在检查267 **修订版。因此,当maven-release-plugin尝试从旧提交中推迟发布准备发布时,构建将失败。

git-push命令失败。
命令输出:
到ssh:// git @ githubenterprise:/user/repo.git
 ![拒绝]管理员->管理员(非快进)
错误:无法将某些引用推送到“ ssh:// git @ githubenterprise:/user/repo.git”
为了防止您丢失历史记录,拒绝了非快速更新
合并远程更改,然后再次推送。

如何仅使Jenkins Git插件签出最新版本(在我的情况下为755 *),而不是尝试构建多个签出(不确定为什么这样做)

git github maven-release-plugin jenkins jenkins-plugins

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

Blogger:布局页面上的标签部分

我为Blogger创建了一个响应主题.因此,由于Layout页面显示的是实际布局的反映,但不利用媒体查询.所有东西都在管理区域中以100%宽度垂直排列(这是预期的).

我的问题:有没有办法可以在某种程度上标记这些部分,以便标签显示在布局页面上,但在查看网站时却没有?目前,在查看布局页面时,有8个部分说"添加小工具",用户无法知道哪个部分是什么.

blogger

0
推荐指数
1
解决办法
1455
查看次数