<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen">
<activity android:name=".MainActivity"
android:launchMode="singleTask"
android:stateNotNeeded="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".AppListActivity"/>
</application>
这里android.category.default用于将此应用程序作为默认启动器,如谷歌启动器,但在运行此应用程序时,其投掷错误默认活动未找到...我已尝试重新启动并使缓存无效多次。谁能帮我...?
答案 0 :(得分:0)
转到“编辑配置”。在“常规”选项卡中,在启动选项下拉列表中,不选择任何内容。现在运行应用程序。
您可以在Windows上使用Control + Shift + A
或在Mac上使用Command + Shift + A
,然后输入编辑配置以将其打开。
答案 1 :(得分:0)
你可以使用它,
package file;
import java.awt.RenderingHints.Key;
import java.io.IOException;
import java.net.URI;
import java.nio.file.FileSystems;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.StandardWatchEventKinds;
import java.nio.file.WatchEvent;
import java.nio.file.WatchKey;
import java.nio.file.WatchService;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.HashMap;
import java.util.Map;
public class file implements Runnable
{
Path path;
public void run()
{
try(WatchService svc = FileSystems.getDefault().newWatchService())
{
System.out.println("1");
Map<WatchKey, Path> keyMap = new HashMap<>();
System.out.println("2");
path = Paths.get("C:/test/edit/");
System.out.println("3");
file.registerAll(path,svc,keyMap);
System.out.println("4");
WatchKey wk = null ;
while(!Thread.currentThread().isInterrupted())
{
do
{
try
{
System.out.println("5");
wk = svc.take();
// path = keyMap.get(wk.watchable());
for(WatchEvent<?> event : wk.pollEvents())
{
System.out.println("6");
WatchEvent.Kind<?> type = event.kind();
System.out.println("7");
path = (Path) wk.watchable();
// Path object = (Path) event.context();
// System.out.println(object.toAbsolutePath());
System.out.println("8");
Path child = path.resolve((Path)event.context());
System.out.println(child);
System.out.println("9");
URI fullPath = child.toAbsolutePath().toUri();
System.out.println("10");
System.out.println(fullPath);
Path newFilePath = Paths.get(fullPath);
if (Files.isDirectory(newFilePath, LinkOption.NOFOLLOW_LINKS))
{
System.out.println("11");
if(type == StandardWatchEventKinds.ENTRY_CREATE)
{
System.out.println("12");
register(newFilePath,keyMap,svc);
// URI uri = child.toUri();
// path = Paths.get(uri);
}
System.out.println("\nThe new folder :"+newFilePath+ "Event :" +type);
}
else
{
System.out.println("\nThe new file :"+child+ "Event :" +type);
}
}
}
catch (InterruptedException e)
{
e.printStackTrace();
}
}while(wk.reset());
}
}
catch (IOException e)
{
e.printStackTrace();
}
}
private static Path register(Path newFilePath, Map<WatchKey, Path> keyMap, WatchService svc) throws IOException
{
System.out.println("a");
Files.walkFileTree(newFilePath.toAbsolutePath(),new SimpleFileVisitor<Path>()
{
public FileVisitResult preVisitDirectory(Path newfilePath, BasicFileAttributes attrs) throws IOException
{
System.out.println("b");
if(attrs.isDirectory())
{
System.out.println("c");
keyMap.put(newFilePath.register(svc, StandardWatchEventKinds.ENTRY_CREATE),newFilePath);
System.out.println("file path in register method : "+newFilePath);
}
System.out.println("d");
return FileVisitResult.CONTINUE;
}
});
return newFilePath;
}
private static Path registerAll(Path path, WatchService svc,Map<WatchKey, Path> keyMap)
{
try {
Files.walkFileTree(path.toAbsolutePath(),new SimpleFileVisitor<Path>()
{
public FileVisitResult preVisitDirectory(Path path, BasicFileAttributes attrs) throws IOException
{
System.out.println("aa");
if(attrs.isDirectory())
{
System.out.println("bb");
keyMap.put(path.register(svc, StandardWatchEventKinds.ENTRY_CREATE),path);
System.out.println("file path in registerAll method : "+path);
}
System.out.println("cc");
return FileVisitResult.CONTINUE;
}
});
}
catch (IOException e)
{
e.printStackTrace();
}
return path;
}
public static void main(String args [])
{
file f = new file();
Thread t = new Thread(f);
t.start();
}
}
答案 2 :(得分:-1)